Skip to content

Commit b2f7328

Browse files
eregonandrykonchin
authored andcommitted
[GR-17457] Only set the callTargetForLambda for stabby lambdas
PullRequest: truffleruby/3839
2 parents aafc401 + 6f5a20e commit b2f7328

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/org/truffleruby/core/proc/ProcCallTargets.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public ProcCallTargets(
3939
RootCallTarget callTargetForProc,
4040
RootCallTarget callTargetForLambda,
4141
Supplier<RootCallTarget> altCallTargetCompiler) {
42+
// both can be set for lambda {} if #lambda is not Kernel#lambda
4243
assert callTargetForProc != null || callTargetForLambda != null;
44+
4345
assert callTargetForProc == null || validProcRootNode(callTargetForProc);
4446
assert callTargetForLambda == null || validLambdaRootNode(callTargetForLambda);
4547

@@ -49,7 +51,7 @@ public ProcCallTargets(
4951
}
5052

5153
public ProcCallTargets(RootCallTarget callTargetForLambda) {
52-
this(callTargetForLambda, callTargetForLambda, null);
54+
this(null, callTargetForLambda, null);
5355
}
5456

5557
public RootCallTarget getCallTargetForProc() {
@@ -80,9 +82,7 @@ private void copySplit(RootCallTarget src, RootCallTarget dst) {
8082

8183
private boolean validProcRootNode(RootCallTarget callTarget) {
8284
final RootNode rootNode = callTarget.getRootNode();
83-
assert rootNode instanceof RubyProcRootNode ||
84-
// RubyLambdaRootNode is used for the ProcCallTargets(RootCallTarget callTargetForLambda) constructor
85-
rootNode instanceof RubyLambdaRootNode : rootNode + " " + rootNode.getClass();
85+
assert rootNode instanceof RubyProcRootNode : rootNode + " " + rootNode.getClass();
8686
return true;
8787
}
8888

src/main/java/org/truffleruby/parser/MethodTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public BlockDefinitionNode compileBlockNode(SourceIndexLength sourceSection, Par
171171
final ProcCallTargets callTargets;
172172
if (isStabbyLambda) {
173173
final RootCallTarget callTarget = lambdaCompiler.get();
174-
callTargets = new ProcCallTargets(callTarget, callTarget, null);
174+
callTargets = new ProcCallTargets(callTarget);
175175
} else if (methodNameForBlock.equals("lambda")) {
176176
callTargets = new ProcCallTargets(null, lambdaCompiler.get(), procCompiler);
177177
} else {

0 commit comments

Comments
 (0)