'this' Typing

c foo(): C { return this; }

D bar(): D { return this; }

class C {
f() {
var x: this;
var c: C;
c = x;
}
}

this <: C

is like:

class C<this extends C> {
f() {
var x: this;
var c: C;
c = x;
}
}

this will no longer work:

class C<this extends C> {
f() {
var x = this;
x = new C();
}
}

because C is not assignment compatible with x, because x : this

Last edited Jan 16, 2013 at 4:24 PM by jonturner, version 1

Comments

No comments yet.