<< §2.3.4.(a) Potential ambiguity | ↑ Table of Contents ↑ | §2.3.4.(c) Actual ambiguity >> |
§2.3.4.(b) Definite ambiguity
A definite ambiguity is given if
- the situation of potential ambiguity according to (a) above is given and
- lifting is requested (either by method binding or explicitly
(§2.3.2)) from the shared base class
B
to any role classR0
that is a common super role forR1
andR2
.
Definite binding ambiguity also occurs in cases of generic declared lifting §2.3.2.(e)
if the specified role R
is unbound and if two independent sub-roles R1
and R2
exist that introduce a playedBy binding to the same base class BX
.
In this case no potential ambiguity is flagged because roles R1
and R2
have no shared bound super-role.
Effect:
Code causing definite ambiguity is required to handleorg.objectteams.LiftingFailedException
.
In cases of definite binding ambiguity lifting will indeed fail except for some corner cases. Such corner cases may arise if lifting already finds an appropriate role in the cache or if an (indirect) subrole of the ambiguously bound role is an unambiguous lift target for the concrete type of the base object at run-time. See also §2.3.5.
Example code (Definite Ambiguity):
1 | team class MyTeam { |
2 | public class SuperRole playedBy MyBase {...} |
3 | public class SubRoleA extends SuperRole playedBy SubBase {...} |
4 | public class SubRoleB extends SuperRole playedBy SubBase {...} |
5 | |
6 | public void useSuperRole(SubBase as SuperRole r) {...} // must declare LiftingFailedException |
7 | } |
<< §2.3.4.(a) Potential ambiguity | ↑ Table of Contents ↑ | §2.3.4.(c) Actual ambiguity >> |