36 lines
557 B
Plaintext
36 lines
557 B
Plaintext
type t {
|
|
void m();
|
|
}
|
|
|
|
class A():t { // no implements necessary
|
|
t state = null;
|
|
void m() {
|
|
state = (this : t); // do we need coercions here? -- yes!
|
|
}
|
|
export t : m;
|
|
}
|
|
|
|
type s <: t { }
|
|
|
|
type u {
|
|
void m();
|
|
}
|
|
|
|
subclass B():s extends A at t implements u {
|
|
super();
|
|
// use of m somewhere
|
|
void m2() {
|
|
m();
|
|
}
|
|
// .: the type of this is s
|
|
// .: the assignment of state = this still works
|
|
// because s is below t
|
|
export s : m;
|
|
export u : m2 as m;
|
|
}
|
|
|
|
void main() {
|
|
u x = new B:u();
|
|
x.m();
|
|
}
|