§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
class R0
that is a common super role for R1
and R2
.
Effect:
Definite ambiguity is a compile time error.
A compiler may still choose to make this error configurable/suppressable
(using the warning token "def-bind-ambiguity"
)
to account for corner cases that may work as desired despite a definite binding ambiguity.
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.
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) {...} |
7 |
} |