--check for scopes --same name works with diff types in diff scopes Class A { a:Int; g():Object { case a of b:Int => b<- b+1; b:String => b<-"Hello"; b:A => b<-self; esac }; h():A { --ret type will be A, least type of C, B, A case self of b:C => b<-(new C) ; b:B => b<- (new B); b:A => b<- (new A); esac }; --check for SELF_TYPE i():A { --ret type will be A, least type of C, B, A case self of b:C => self ; b:B => (new C); esac }; --check for SELF_TYPE j():A { --ret type will be A, least type of C, B, A case self of b:B => (new C); b:C => self ; esac }; --check for SELF_TYPE k():Object { --ret type will be A, least type of C, B, A case self of b:B => self ; b:C => self ; esac }; --check for SELF_TYPE l():Object { --ret type will be A, least type of C, B, A case self of b:B => (new B).mb() ; b:C => self ; esac }; }; Class B inherits A { b:Int; mb():SELF_TYPE { self }; }; Class C inherits B { c:Int; }; Class Main{ main():Int{ 1 }; };