extend String test assert not X.visitedExtensionTest X.visitedExtensionTest = true def foo(i as int) as int return i def foo(i as int, j as int) as int test assert not X.visitedMethodTest X.visitedMethodTest = true body return i + j def insert(index as int, value as int) as String return '' # return .insert(index, value.toString) def returnThis as String return this extend Object def bar(i as int) as int return i * 2 class MyObject def bar(i as int) as int # no 'new' or 'override' is required to mask out the extension method of Object return i + 1 class X shared var _visitedExtensionTest as bool pro visitedExtensionTest from var var _visitedMethodTest as bool pro visitedMethodTest from var def main # test that tests on extension methods are run assert .visitedExtensionTest assert .visitedMethodTest s = 'aoeu' # test overload within the extension assert s.foo(5) == 5 assert s.foo(5, 6) == 11 # test overload against the class assert s.insert(2, 'XX') == 'aoXXeu' # assert s.insert(2, 3) == '' TODO # test masking extension methods assert Object().bar(2) == 4 assert MyObject().bar(2) == 3