Files
wren/test/implicit_receiver/nested_class.wren
T
Bob Nystrom e3b3fef0fb feat: make this the implicit receiver for method calls inside class bodies
In the compiler, when a bare name is encountered inside a class definition and it does not resolve to a local variable or global, emit an implicit `this.` load before the call, enabling getter, setter, and method calls without explicit receiver. Update all benchmark, builtin, and test files to remove redundant `this.` qualifiers, and add comprehensive test suites for implicit receiver behavior across instance, inherited, static, nested, and shadowing scenarios.
2014-02-13 01:33:35 +00:00

48 lines
870 B
Plaintext

class Outer {
getter {
IO.print("outer getter")
}
setter = value {
IO.print("outer setter")
}
method(a) {
IO.print("outer method")
}
test {
getter // expect: outer getter
setter = "value" // expect: outer setter
method("arg") // expect: outer method
class Inner {
getter {
IO.print("inner getter")
}
setter = value {
IO.print("inner setter")
}
method(a) {
IO.print("inner method")
}
test {
getter // expect: inner getter
setter = "value" // expect: inner setter
method("arg") // expect: inner method
}
}
(new Inner).test
getter // expect: outer getter
setter = "value" // expect: outer setter
method("arg") // expect: outer method
}
}
(new Outer).test