'This' type

Neal Gafter neal at gafter.com
Tue Mar 3 13:26:25 PST 2009


On Tue, Mar 3, 2009 at 1:18 PM, Marek Kozieł <develop4lasu at gmail.com> wrote:
> Oh.
>
> I get it now.
>
> Yes A is a subtype of Collection<A>
>
> but after
>
> B extends A
>
> B will be Collection<B> from B point of view
>
> B will be Collection<A> from A point of view
>
> In base relation is same as one created by overloaded methods.

So if we have a class C that is a sibling of B (a child of A), then
from A's point of view we can place a C into the collection (because C
is a subtype of A).  But then from B's point of view the collection
should contain only Bs and not any Cs.  So when B pulls something out
of the collection we could get a ClassCastException.

That's the kind of thing you need to demonstrate can't happen in order
to show this change is a sound extension of the type system.



More information about the coin-dev mailing list