Skip to content

Commit 84aff72

Browse files
committed
No need to set the constants for updateAnonymousChildrenModules()
1 parent 7a112e4 commit 84aff72

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/main/java/org/truffleruby/core/module/ModuleFields.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,24 @@ public void afterConstructed() {
163163
getName();
164164
}
165165

166-
public RubyConstant getAdoptedByLexicalParent(
167-
RubyContext context,
168-
RubyModule lexicalParent,
169-
String name,
166+
public RubyConstant getAdoptedByLexicalParent(RubyContext context, RubyModule lexicalParent, String name,
170167
Node currentNode) {
168+
return getAdoptedByLexicalParent(context, lexicalParent, name, currentNode, true);
169+
}
170+
171+
private RubyConstant getAdoptedByLexicalParent(RubyContext context, RubyModule lexicalParent, String name,
172+
Node currentNode, boolean setConstant) {
171173
assert name != null;
172174

173-
RubyConstant previous = lexicalParent.fields.setConstantInternal(
174-
context,
175-
currentNode,
176-
name,
177-
rubyModule,
178-
null);
175+
RubyConstant previous = null;
176+
if (setConstant) {
177+
previous = lexicalParent.fields.setConstantInternal(
178+
context,
179+
currentNode,
180+
name,
181+
rubyModule,
182+
null);
183+
}
179184

180185
if (!hasFullName()) {
181186
// Tricky, we need to compare with the Object class, but we only have a Class at hand.
@@ -208,7 +213,8 @@ public void updateAnonymousChildrenModules(RubyContext context) {
208213
context,
209214
rubyModule,
210215
entry.getKey(),
211-
null);
216+
null,
217+
false);
212218
}
213219
}
214220
}

0 commit comments

Comments
 (0)