--dynamic dispatch expression Class C inherits A { b:B; z:Z; manc5():Int{ { (new B).mana1(); --trying to access method of A from B (self).manc6(); --trying to access method of C from A (new B).man5(1); --invalid argument type (new B).man7(self); --valid arg b.man7(new B); --invalid arg } }; manc6():Int{ { z<-(new C).man6(); --man6 returns SELF_TYPE, wrong storing type C in Z } }; }; Class Z inherits B { ab:A; xy:Undef; manz1():Int{ self.manc5() --trying to access method of C from Z }; manz2():Int{ ab.invalid() --unkown method }; manz4():A{ --wrong ret type Object for A xy.manz3() -- undefined type of xy }; manz3():Z { manz45() }; }; Class A inherits B{ m:Int; n:C; u:Z; v:B; mana1():Int { { self.man(); --valid call...valid ret type self.man8(1, true, 2); -- valid call self.man8(true, true, true); -- invalid arg types self.man8(1, true); -- invalid number of args self.man8(true, 1); -- invalid type and number of args self.man8(1, true, 2, 6); -- invalid number of args } }; mana2():Int { { m<-23; m<-(new B).man3(m); --valid call...valid ret type m<- (new A).man3(m); --invalid call... m<-(new A).man6(m); --valid call...invalid ret type n<-(new B).man6(m); --invalid assignment of type A to type C v<-(new B).man6(m); --valid assignment of type B to type B u<-(new B).man6(m); --invalid assignment of type B to type Z } }; mana3():Z { self.man6(1) --invalid ret of type A to type Z (check of SELF_TYPE) }; mana3():A { self.man6(1) --valid ret of type A to type A (check of SELF_TYPE) }; mana3():B { self.man6(1) --invalid ret of type A to type A (check of SELF_TYPE) }; mana3():C { self.man6(1) --valid 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 }; };