Skip to content

Commit 308f6dc

Browse files
committed
No need to check the hierarchy Assumption for object.is_a?(SomeClass)
* This avoids unnecessary invalidations on include/prepend.
1 parent 4dea5a3 commit 308f6dc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/org/truffleruby/language/objects/IsANode.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ protected boolean isAMetaClassCached(Object self, RubyModule module,
5252
return result;
5353
}
5454

55+
/** If we are checking if an object.is_a?(SomeClass), then no matter hierarchy changes the superclass chain never
56+
* changes. The superclass is always set when creating the RubyClass on TruffleRuby, i.e. it cannot be set later by
57+
* Class#initialize. */
5558
public Assumption getHierarchyUnmodifiedAssumption(RubyModule module) {
59+
if (module instanceof RubyClass) {
60+
return Assumption.ALWAYS_VALID;
61+
}
5662
return module.fields.getHierarchyUnmodifiedAssumption();
5763
}
5864

0 commit comments

Comments
 (0)