Ticket #192 (closed enhancement: fixed)
Improve support for generic roles
| Reported by: | stephan | Owned by: | stephan |
|---|---|---|---|
| Priority: | major | Milestone: | OTDT_1.3.0_M4 |
| Component: | language | Version: | 1.2.5 |
| Keywords: | Cc: |
Description
It should be clarified in the OTJLD what can and what cannot be done with generic roles.
spawning from #190:
After generic base classes had to be ruled out (cf. OTJLD §2.1.2(e)) we are speaking about examples of this kind:
1 public team class MyTeam { 2 protected class MyRole<T> playedBy MyBaseClass { 3 void rm() { ... } 4 void rm() <- after void bm(); // RAW TYPE MyRole! 5 } 6 protected class PlainRole playedBy OtherBaseClass { 7 void receiveRole(MyRole<String> r) { ... } 8 void recieveRole(MyRole<String> r) <- after void processBase(MyBaseClass b); 9 } 10 void teamMethod(MyBaseClass as MyRole<String> r, MyBaseClass b) { 11 MyRole<Date> otherRole = new MyRole<Date>(b); 12 } 13 }
Rules have to make sure, that every instantiation of MyRole substitutes the parameter T with a real type. Let's distinguish these cases
- Explicit creation using role constructor (line 11) - OK.
- Declared lifting (line 10) - OK.
(cannot allow MyBaseClass as MyRole - is a raw type). - Lifting of callin parameter, callout return (e.g., line 8) - OK
- Lifting call target in callin binding (line 4): NOT OK missing type argument
We could still allow raw types and just issue a warning, but since these uses occur in the very context where the generic role is defined, admitting raw types here seems to undermine the original intentions of generics.
Thus, it seems we cannot accept callin bindings in generic role classes. This is unfortunate, but unavoidable.
all news
RSS feed