Skip to content

Commit 979c0e3

Browse files
committed
Publish an autoload constant only once
1 parent 7426b89 commit 979c0e3

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ public boolean isAutoloadingThreadAndUnset() {
7171
return isAutoloadingThread() && !hasUnpublishedValue();
7272
}
7373

74-
public boolean hasUnpublishedValue() {
74+
public boolean shouldPublish() {
75+
return hasUnpublishedValue() && !isPublished();
76+
}
77+
78+
private boolean hasUnpublishedValue() {
7579
assert isAutoloadingThread();
7680
return unpublishedValue != null;
7781
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected Object autoloadConstant(
129129
try {
130130
callRequireNode.call(coreLibrary().mainObject, "require", feature);
131131
} finally {
132-
if (autoloadConstant.hasUnpublishedValue()) {
132+
if (autoloadConstant.shouldPublish()) {
133133
autoloadConstant.publish(getContext(), constant);
134134
}
135135
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private boolean requireConsideringAutoload(String feature, String expandedPath,
129129
final List<RubyConstant> releasedConstants = featureLoader.getAutoloadConstants(expandedPath);
130130
for (RubyConstant constant : releasedConstants) {
131131
if (constant.getAutoloadConstant().isAutoloadingThread() && !alreadyAutoloading.contains(constant)) {
132-
if (constant.getAutoloadConstant().hasUnpublishedValue()) {
132+
if (constant.getAutoloadConstant().shouldPublish()) {
133133
constant.getAutoloadConstant().publish(getContext(), constant);
134134
}
135135

0 commit comments

Comments
 (0)