""" Testing: * Nested if-inherits. I doubt it comes up much, but it's supported for completeness. * Backing up. (See below.) """ class One get foo as int return 1 class SubOne inherits One get sub as int return 3 get makeOne as One return One() class Two get bar as int return 2 class Test shared def main Test().run def run .check(One(), 1) .check(Two(), 2) .backUp1(SubOne()) .backUp2(SubOne()) def check(obj as Object, value as int) if obj inherits One assert obj.foo==value # using a One member with no casting if obj inherits SubOne assert obj.sub==3 # using a SubOne member with no casting assert obj.foo==value # can still use a One member else if obj inherits Two assert obj.bar==value # using a Two member with no casting else throw Exception('fall through') def backUp1(obj as One) oldObj = obj assert oldObj is obj if obj inherits SubOne assert oldObj is obj obj = obj.makeOne # assert obj is not oldObj assert obj is not oldObj def backUp2(obj as Object) if obj inherits One if obj inherits SubOne for other in [One(), One()] if .willBackUp(obj) # here we have an if-statement with no "if inherits" in between the if-inherits above and the assignment below obj = other break def willBackUp(obj as SubOne) as bool return true