--static dispatch expression Class C inherits A { manc5():Int{ { (new C)@B.mana1(); --trying to access method of A from B (self)@A.manc6(); --trying to access method of C from A (self)@B.man5(1); --invalid argument type (self)@B.man7(self); --valid arg (self)@B.man7(new B); --invalid arg } }; manc6():Int{ { (new B)@C.man5(); --new B is not derived from C (new A)@C.man5(); --new A is not derived from C (new A)@C.man5(); --new A is not derived from C and man6 returns SELF_TYPE } }; }; Class Z inherits B { manz1():Int{ self@C.manc5() --self (Z) not derived from C }; manz2():Int{ self@U.manc5() --undefined type U }; }; Class A inherits B{ m:Int; n:C; mana1():Int { { self@A.man(); --valid call...valid ret type m@A.man(); --m not derived from A self@B.man8(1, true, 2); -- valid call self@B.man8(1, true); -- invalid number of args self@B.man8(1, true, 2, 6); -- valid number of args } }; mana2():Int { { m<-23; m<-(new B)@B.man3(m); --valid call...valid ret type m<- (new B)@A.man3(m); --invalid call... m<-(new B)@B.man6(m); --valid call...invalid ret type n<-(new B)@B.man6(m); --invalid assignment of type A to type C } }; mana3():C { self@B.man6(1) --invalid ret of type A to type C (check of SELF_TYPE) }; }; Class B { r:Int; s:Bool; man():Int { r<-1 }; man3(n:Int):Int { r<-n }; man4(n:Int, m:Bool):Bool { { r<-n; s<-m; } }; man5(n:B ):Int { r<-1 }; man6(n:Int ):SELF_TYPE { self }; man7(n:A ):Int { r<-1 }; man8(n:Int, m:Bool, h:Int ):Int { r<-1 }; }; class Main { main():Int { 1 }; };