class Foo { getClosure() { fun closure() { return this.toString(); } return closure; } toString() { return "Foo"; } } var closure = Foo().getClosure(); print closure(); // expect: Foo