class Foo where TBar must be Bar def add(bar as TBar) assert bar.value>40 class Bar get value as int return 42 class Baz inherits Bar get value as int is override return 43 class Test def main is shared f as Foo = Foo() f.add(Bar()) f.add(Baz()) g as Foo = Foo() g.add(Baz())