↑ Table of Contents ↑ | §2.3.4.(b) Definite ambiguity >> |
§2.3.4.(a) Potential ambiguity
A potential ambiguity is given,
if two role classes R1
and R2
exist such that
R1
andR2
are played by the same base classB
, andR1
andR2
have a common super roleR0
, which is also bound to a base classB0
, and- neither role class
R1
norR2
is a (indirect) sub-class of the other.
Effect:
In this case the compiler issues a warning, stating that theB
may not be liftable, because both role classes R1
and R2
are candidates and there is no reason to prefer one over the other.
If no potential ambiguity is detected, lifting will always be unambiguous.
In the above situation, trying to lift an instance of type B
to the role type
R0
is an illegal lifting request. If R0
is bound
to the same base class B
as its sub-roles R1
and R2
are,
role R0
is unliftable, meaning that no instance of R0
can ever by obtained by lifting.
Example code (Potential Ambiguity):
1 | team class MyTeam { |
2 | public class SuperRole playedBy MyBase {...} |
3 | public class SubRoleA extends SuperRole {...} |
4 | public class SubRoleB extends SuperRole {...} |
5 | } |
↑ Table of Contents ↑ | §2.3.4.(b) Definite ambiguity >> |