Skip to content

Commit 9d9cb1f

Browse files
committed
Remember the node which set the unpublishedValue for Module#const_source_location
1 parent b56a357 commit 9d9cb1f

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ private RubyConstant setConstantInternal(RubyContext context, Node currentNode,
498498
} else {
499499
if (previous.isAutoload() && previous.getAutoloadConstant().isAutoloadingThread() &&
500500
!previous.getAutoloadConstant().isPublished()) {
501-
previous.getAutoloadConstant().setUnpublishedValue(value);
501+
previous.getAutoloadConstant().setUnpublishedValue(value, currentNode);
502502
return previous;
503503
}
504504
}

src/main/java/org/truffleruby/language/AutoloadConstant.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public final class AutoloadConstant {
2323
private final String autoloadPath;
2424
private volatile ReentrantLock autoloadLock;
2525
private Object unpublishedValue = null;
26+
private Node unpublishedValueNode = null;
2627
private boolean published = false;
2728

2829
public AutoloadConstant(Object feature) {
@@ -80,21 +81,23 @@ public Object getUnpublishedValue() {
8081
return unpublishedValue;
8182
}
8283

83-
public void setUnpublishedValue(Object unpublishedValue) {
84+
public void setUnpublishedValue(Object unpublishedValue, Node currentNode) {
8485
assert isAutoloadingThread();
8586
assert RubyGuards.assertIsValidRubyValue(unpublishedValue);
8687
this.unpublishedValue = unpublishedValue;
88+
this.unpublishedValueNode = currentNode;
8789
}
8890

8991
public boolean isPublished() {
9092
assert isAutoloadingThread();
9193
return published;
9294
}
9395

94-
public void publish(RubyContext context, RubyConstant constant, Node node) {
96+
public void publish(RubyContext context, RubyConstant constant) {
9597
assert isAutoloadingThread();
9698
assert hasUnpublishedValue();
9799
this.published = true;
98-
constant.getDeclaringModule().fields.setConstant(context, node, constant.getName(), getUnpublishedValue());
100+
constant.getDeclaringModule().fields.setConstant(context, unpublishedValueNode, constant.getName(),
101+
unpublishedValue);
99102
}
100103
}

src/main/java/org/truffleruby/language/constants/GetConstantNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected Object autoloadConstant(
130130
callRequireNode.call(coreLibrary().mainObject, "require", feature);
131131
} finally {
132132
if (autoloadConstant.hasUnpublishedValue()) {
133-
autoloadConstant.publish(getContext(), constant, this);
133+
autoloadConstant.publish(getContext(), constant);
134134
}
135135
}
136136

src/main/java/org/truffleruby/language/loader/RequireNode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private boolean requireConsideringAutoload(String feature, String expandedPath,
130130
for (RubyConstant constant : releasedConstants) {
131131
if (constant.getAutoloadConstant().isAutoloadingThread() && !alreadyAutoloading.contains(constant)) {
132132
if (constant.getAutoloadConstant().hasUnpublishedValue()) {
133-
constant.getAutoloadConstant().publish(getContext(), constant, this);
133+
constant.getAutoloadConstant().publish(getContext(), constant);
134134
}
135135

136136
final boolean undefined = GetConstantNode.autoloadUndefineConstantIfStillAutoload(constant);

0 commit comments

Comments
 (0)