Interface level bounded polymorphism problem
Posted: 1 Jun 2019 12:38
Hello Thomas,
am sorry to bother again with bounded polymorphism, but please have a look on below case (in build 902):
Interesting is, that when the four outcommented lines for the ruleList property are enabled, then it compiles.
am sorry to bother again with bounded polymorphism, but please have a look on below case (in build 902):
Code: Select all
interface rule
properties
name : string (o).
end interface rule
%===
interface grammar{@RuleSite}
%properties
% ruleList : @RuleSite*.
predicates
getRule_nd : () -> @RuleSite nondeterm.
predicates
tryGetRule : (string Name) -> @RuleSite determ.
end interface grammar
%===
interface grammarSupportSite{@RuleSite}
%properties from grammar{@RuleSite}
% ruleList
predicates from grammar{@RuleSite}
getRule_nd/0->
end interface grammarSupportSite
%===
interface grammarSupport{@RuleSite}
predicates from grammar{@RuleSite}
tryGetRule/1->
end interface grammarSupport
%---
class grammarSupport{@RuleSite} : grammarSupport{@RuleSite}
where @RuleSite supports rule
constructors
new : (grammarSupportSite{@RuleSite} Site).
end class grammarSupport
%---
implement grammarSupport{@RuleSite}
supports grammarSupportSite{@RuleSite}
facts
grammarSite : grammarSupportSite{@RuleSite}.
ruleTree : redBlackTree::tree{string, @RuleSite} := redBlackTree::emptyUnique().
delegate
interface grammarSupportSite{@RuleSite} to grammarSite
clauses
new(Site) :-
grammarSite := Site,
foreach Rule = getRule_nd() do % throws error c504: The expression has type 'Rule$',
% which is incompatible with the type '@RuleSite'
ruleTree := redBlackTree::insert(ruleTree, Rule:name, Rule)
end foreach.
clauses
tryGetRule(Name) = redBlackTree::tryLookUp(ruleTree, Name).
end implement grammarSupport