Problems with Brole playedBy Arole [message #568060] |
Fri, 12 February 2010 12:06 |
Eugene Hutorny Messages: 110 Registered: January 2010 |
Senior Member |
|
|
Hi Stephan,
I've made some more experiments with OT/J and got some more questions.
My teams are declares as the following (complete source http://hutorny.in.ua/wp-content/uploads/2010/02/exer14.zip)
public team class Ateam {
public class Arole playedBy Aclass {
//...
}
}
public team class Bteam {
private final Ateam ateam;
public class Brole playedBy Arole<@ateam> {
//...
}
public Brole lift(Arole<@ateam> as Brole brole) {
return brole;
}
}
public team class Cteam extends Ateam {
public class Crole extends Arole playedBy Aclass {
}
}
For the following code compiler generates error: The method lift(Arole<@bteam.ateam>) in the type Bteam is not applicable for the arguments (Arole<@ateam>)
Arole<@ateam> arole = ateam.lift(aclass);
bteam.lift(arole);
How to make the type applicable?
The following code fails with class cast exception:
final Cteam cteam = new Cteam();
final Bteam dteam = new Bteam(cteam);
within(cteam) {
within(dteam) {
aclass.run();
}
}
Exception in thread "main" java.lang.ClassCastException: ua.in.hutorny.otj.exer14.Cteam$__OT__Crole
at ua.in.hutorny.otj.exer14.Bteam$__OT__Brole._OT$run$base(Btea m.java)
at ua.in.hutorny.otj.exer14.Bteam$__OT__Brole.run(Bteam.java:21 )
|
|
|
Powered by
FUDForum. Page generated in 0.02672 seconds