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.
This commit is contained in:
Bob Nystrom
2014-02-13 01:33:35 +00:00
parent c04865df2e
commit e3b3fef0fb
13 changed files with 217 additions and 51 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
class Outer {
method {
IO.print(this.toString) // expect: Outer
IO.print(this) // expect: Outer
fn {
IO.print(this.toString) // expect: Outer
IO.print(this) // expect: Outer
class Inner {
method {
IO.print(this.toString) // expect: Inner
IO.print(this) // expect: Inner
}
toString { return "Inner" }
}