Skip to content

Commit 215c707

Browse files
committed
Refactor handling of Nodes.ForwardingSuperNode
1 parent 13e4bb0 commit 215c707

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ public boolean getNeverAssignInParentScope() {
349349
return !isBlock();
350350
}
351351

352+
/** A way to check current scope is a module/class. If in a block, isModuleBody is always false. */
352353
public boolean isModuleBody() {
353354
return isModuleBody;
354355
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,15 +1531,13 @@ public RubyNode visitForwardingSuperNode(Nodes.ForwardingSuperNode node) {
15311531
boolean insideDefineMethod = false;
15321532
var environment = this.environment;
15331533
while (environment.isBlock()) {
1534-
if (environment.isModuleBody()) { // TODO: when could we be in a block and in a module body at the same time?
1535-
return assignPositionAndFlags(node, new ZSuperOutsideMethodNode(insideDefineMethod));
1536-
} else if (Objects.equals(environment.literalBlockPassedToMethod, "define_method")) {
1534+
if (Objects.equals(environment.literalBlockPassedToMethod, "define_method")) {
15371535
insideDefineMethod = true;
15381536
}
15391537
environment = environment.getParent();
15401538
}
15411539

1542-
if (environment.isModuleBody() || environment.isTopLevelScope()) {
1540+
if (environment.isModuleBody()) {
15431541
return assignPositionAndFlags(node, new ZSuperOutsideMethodNode(insideDefineMethod));
15441542
}
15451543

0 commit comments

Comments
 (0)