diff --git a/src/main/java/org/truffleruby/core/module/ModuleFields.java b/src/main/java/org/truffleruby/core/module/ModuleFields.java index c4571f89e596..e2a59c474319 100644 --- a/src/main/java/org/truffleruby/core/module/ModuleFields.java +++ b/src/main/java/org/truffleruby/core/module/ModuleFields.java @@ -112,6 +112,7 @@ public static void debugModuleChain(RubyModule module) { * map of refined classes and modules (C) to refinement modules (R). */ private final ConcurrentMap refinements = new ConcurrentHashMap<>(); + /** Only set for a Module and not a Class since there is no usage of it for a Class */ private final CyclicAssumption hierarchyUnmodifiedAssumption; // Concurrency: only modified during boot @@ -141,7 +142,9 @@ public ModuleFields( this.lexicalParent = lexicalParent; this.givenBaseName = givenBaseName; this.rubyModule = rubyModule; - this.hierarchyUnmodifiedAssumption = new CyclicAssumption("hierarchy is unmodified"); + this.hierarchyUnmodifiedAssumption = rubyModule instanceof RubyClass + ? null + : new CyclicAssumption("hierarchy is unmodified"); classVariables = new ClassVariableStorage(language); start = new PrependMarker(this); this.includedBy = rubyModule instanceof RubyClass ? null : new ConcurrentWeakSet<>(); @@ -799,6 +802,10 @@ public boolean isAnonymous() { return !this.hasFullName; } + private boolean isClass() { + return rubyModule instanceof RubyClass; + } + public boolean isRefinement() { return isRefinement; } @@ -824,7 +831,9 @@ public String toString() { } public void newHierarchyVersion() { - hierarchyUnmodifiedAssumption.invalidate(getName()); + if (!isClass()) { + hierarchyUnmodifiedAssumption.invalidate(getName()); + } if (isRefinement()) { getRefinedModule().fields.invalidateBuiltinsAssumptions(); @@ -884,6 +893,7 @@ private void newMethodVersion(String methodToInvalidate) { } public Assumption getHierarchyUnmodifiedAssumption() { + assert !isClass(); return hierarchyUnmodifiedAssumption.getAssumption(); }