Ticket #237 (closed enhancement: fixed)
Generic declared lifting should work accross team inheritance
| Reported by: | stephan | Owned by: | stephan |
|---|---|---|---|
| Priority: | major | Milestone: | OTDT_1.2.8 |
| Component: | compiler | Version: | 1.2.7 |
| Keywords: | Cc: | sbeaumont@… |
Description
sbeaumont provided an example with roles bound to Object so he could use declared lifting:
public team class SuperTeam { protected class GeneralizedRole playedBy Object { /* ... */ } public void processRole(Object as GeneralizedRole o) { /* ... */ } }
He then implemented a sub-team providing concrete roles with more specific bindings:
public team class SubTeam extends SuperTeam { protected class SpecificRole extends GeneralizedRole playedBy SpecificBase { /* ... */ } }
While this works it would be even better if no playedBy was required in the SuperTeam. This could in principle be achieved by using generic declared lifting (see OTJLD §2.3.2(e)) like:
public <RBase base GeneralizedRole> void processRole(RBase as GeneralizedRole o) { /* ... */ }
However, the compiler now complains that the type RBase is not compatible (even to itself ;-). Comparing the OTJLD and the compiler implementation, the compiler is stricter than needed: while it is correct that for team SuperTeam no class can be found that is a base class of GeneralizedRole, the situation looks different for SubTeam.
So, we might want to make the implementation more capable by letting it compile the method as given above. Now, calling processRole on a variable of type SuperTeam will never typecheck for the given reason, however, using the same method on SubTeam should allow arguments of exactly those classes for which SubTeam provides a playedBy binding with a role compatible to GeneralizedRole, in this particular case: SpecificBase.
all news
RSS feed