'This' type (original) (raw)

Marek Kozieł develop4lasu at gmail.com
Tue Mar 3 13:42:47 PST 2009


W dniu 3 marca 2009 22:26 użytkownik Neal Gafter <neal at gafter.com> napisał:

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 > > but after > > B extends A > > B will be Collection from B point of view > > B will be Collection 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.

That's the reason why I wander if 'This' should be allowed as input parameter type(what conditions should be respected ...).

In basic it's designed for return types and return type parameters.

But notice that B b ; A a=b; would be invalid while this comes from generic rules(extends would be partial).

-- Pozdrowionka. / Regards. Lasu aka Marek Kozieł

http://lasu2string.blogspot.com/



More information about the coin-dev mailing list