[otj-users] Binding inheritance and covariance

Carsten Pfeiffer carsten.pfeiffer at alumni.tu-berlin.de
Tue Oct 2 10:59:47 CEST 2007


Am Dienstag, 2. Oktober 2007 schrieb Stephan Herrmann:

Hi,

> Yes! Either the base-call result ;-)
> OR null :(
> But no other value is possible.

perfect.

> The contract of this method is:
>   "I'll return a value,
>   the type of which you're free to CHOOSE from all subtypes of List
>   AFTER I've implemented the method."

Right right, my bad. I was only thinking of the restriction to "subclass of 
List", but not of "*exactly this* subclass of List".

> Not very useful in normal settings, ;-)
> but for replace callins it looks neat, doesn't it?

Yes, perfect then :-)

> PS: I just tried to cheat the java compiler:
> 	<E extends List> E getList() {
> 		return (E)(new ArrayList());
> 		// telling the compiler: please insert a cast,
> 		// I'll tell you at runtime which type to cast to!

Evil! ;-)

Cheers,
Carsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 447 bytes
Desc: This is a digitally signed message part.
Url : http://collegium-musicum.tu-berlin.de/pipermail/otj-users/attachments/20071002/f548db04/attachment.pgp


More information about the otj-users mailing list