Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -327,6 +327,8 @@ public final boolean isClassScope() {
}

public final boolean isClassMemberScope() {
var effectiveScope = skipLambdaScopes();
var parent = effectiveScope.parent;
if (parent == null) return false;

return parent.isClassScope()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@
import org.pkl.core.ast.ExpressionNode;
import org.pkl.core.ast.member.ClassMethod;
import org.pkl.core.runtime.Identifier;
import org.pkl.core.runtime.VmFunction;
import org.pkl.core.runtime.VmUtils;

public abstract class InvokeSuperMethodNode extends ExpressionNode {
Expand Down Expand Up @@ -66,6 +67,10 @@ protected Object eval(

protected ClassMethod findSupermethod(VirtualFrame frame) {
var owner = VmUtils.getOwner(frame);
while (owner instanceof VmFunction) {
owner = owner.getEnclosingOwner();
}
assert owner != null : "VmFunction always has a parent";
assert owner.isPrototype();

var superclass = owner.getVmClass().getSuperclass();
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
res1 = "ab"
res2 = "cd"
res3 = "e and f"
Loading