""" Cobra lets you "call" a System.Type to instantiate it (just like Python with classes). The type of such a call is dynamic (as opposed to, say, System.Object). """ class Test def main t = A assert t.getType inherits Type # .warning. always x = t() assert x inherits A assert x.foo == 'foo' t = B x = t() assert x inherits B assert x.bar == 'bar' tn = A to ? # test a nilable type y = tn() assert y inherits A assert y.foo == 'foo' class A get foo as String return 'foo' class B get bar as String return 'bar'