Fix super method call inside let expression (#1383)

Fixes #1309

The issue was that super calls were blocked inside let expressions
because:
1. The compiler's isClassMemberScope() check didn't skip over lambda
scopes created by let expressions
2. The runtime's findSupermethod() didn't traverse past VmFunction
owners to find the actual class prototype

Changes:
- SymbolTable.java: Updated isClassMemberScope() to skip lambda scopes
before checking if the parent is a class or module scope
- InvokeSuperMethodNode.java: Updated findSupermethod() to skip
VmFunction owners when looking for the class prototype

Added regression tests covering:
- Super method calls inside let expressions
- Super property access inside let expressions
- Nested let expressions with super calls

---------

Co-authored-by: Jen Basch <jbasch@apple.com>
This commit is contained in:
Akshat Anand
2026-01-10 09:29:20 +05:30
committed by GitHub
parent 3595c03078
commit 9d385f2194
4 changed files with 56 additions and 2 deletions
@@ -0,0 +1,44 @@
open class A {
function foo() = "a"
}
class B extends A {
function foo() =
let (bar = "b")
super.foo() + bar
}
local b = new B {}
res1 = b.foo()
// Also test with property access
open class C {
value = "c"
}
class D extends C {
result =
let (x = "d")
super.value + x
}
local d = new D {}
res2 = d.result
// Test with nested let expressions
open class E {
function getValue() = "e"
}
class F extends E {
function getValue() =
let (x = "f")
let (y = " and " + x)
super.getValue() + y
}
local f = new F {}
res3 = f.getValue()
@@ -0,0 +1,3 @@
res1 = "ab"
res2 = "cd"
res3 = "e and f"