mirror of
https://github.com/apple/pkl.git
synced 2026-03-23 09:31:06 +01:00
Improve method.isConst() check in InvokeSuperMethodNode
Check const-ness every time a method is resolved instead of every time it is called.
This commit is contained in:
committed by
Daniel Chao
parent
5de90d5868
commit
3a31188cc1
@@ -54,10 +54,6 @@ public abstract class InvokeSuperMethodNode extends ExpressionNode {
|
||||
@Cached("findSupermethod(frame)") ClassMethod supermethod,
|
||||
@Cached("create(supermethod.getCallTarget(sourceSection))") DirectCallNode callNode) {
|
||||
|
||||
if (needsConst && !supermethod.isConst()) {
|
||||
CompilerDirectives.transferToInterpreter();
|
||||
throw exceptionBuilder().evalError("methodMustBeConst", methodName.toString()).build();
|
||||
}
|
||||
var args = new Object[2 + argumentNodes.length];
|
||||
args[0] = VmUtils.getReceiverOrNull(frame);
|
||||
args[1] = supermethod.getOwner();
|
||||
@@ -77,7 +73,13 @@ public abstract class InvokeSuperMethodNode extends ExpressionNode {
|
||||
|
||||
// note the use of getMethod() rather than getDeclaredMethod()
|
||||
var supermethod = superclass.getMethod(methodName);
|
||||
if (supermethod != null) return supermethod;
|
||||
if (supermethod != null) {
|
||||
if (needsConst && !supermethod.isConst()) {
|
||||
CompilerDirectives.transferToInterpreter();
|
||||
throw exceptionBuilder().evalError("methodMustBeConst", methodName.toString()).build();
|
||||
}
|
||||
return supermethod;
|
||||
}
|
||||
|
||||
CompilerDirectives.transferToInterpreter();
|
||||
var parent = owner.getParent();
|
||||
|
||||
Reference in New Issue
Block a user