% Demonstrate how unification of Java variables works
:- eval(test024()).

% Assume IBMPortfolio is a subclass of Portfolio

test024() :-
	println(["==========test024=========="]),
	IBM_P=ws.prova.examples.IBMPortfolio(),
	% A relationship that holds for the subclass
	assert(mustbe(ws.prova.examples.IBMPortfolio.P,big)),
	% Query the relationship providing a superclass variable
	mustbe(ws.prova.examples.Portfolio.IP,big),
	% Since we query for something more general than the stored fact,
	%   the result is the subclass for which the relationship holds.
	println(["Must print an IBMPortfolio variable=",ws.prova.examples.Portfolio.IP]),
	
	% A relationship that holds for the superclass
	assert(mustbe(ws.prova.examples.Portfolio.P2,balanced)),
	% Query the relationship providing a subclass variable
	mustbe(ws.prova.examples.IBMPortfolio.IP2,balanced),
	% The type of the variable stays the same, since
	%    the relationships for superclasses hold for subclasses as well
	println(["Must print an IBMPortfolio variable=",ws.prova.examples.IBMPortfolio.IP2]).
