Re-opened classes should not reset superclass to 'Object' - #1315
Open
apiology wants to merge 1 commit into
Open
Conversation
YARD fills in `Object` as the superclass of every class it never saw a
superclass clause on, including a bare `class Foo` reopening, and keeps
no record of which case it was. These three produce byte-identical
`P(Object)` proxies, and that survives the yardoc round-trip:
class Reopened; def a; end; end # reopening, asserts nothing
class Fresh; end # genuinely Object
class Explicit < Object; end # declared
Store#get_superclass takes the first recorded reference, so a gem
reopening a class could shadow the real superclass declared elsewhere.
With activesupport in the bundle
(`active_support/core_ext/date_time/blank.rb` reopens `class DateTime`),
`get_superclass('DateTime')` returned `Object` instead of RBS's `Date`,
so `Comparable` was never reached:
get_method_stack('Date', '<') # => [Comparable#<]
get_method_stack('DateTime', '<') # => []
which reports `Unresolved call to <` for `some_date_time < other` and,
for a `Date, DateTime` union receiver,
`Unresolved call to > on Date, DateTime`.
A class with no superclass reference already resolves to Object through
Store#try_special_superclasses, so dropping these references at the
mapper loses nothing and leaves get_superclass with no conflict to
arbitrate.
`BasicObject` references are kept. The only class YARD defaults to a
BasicObject superclass is Object itself, whose superclass genuinely is
BasicObject, so the recorded reference is correct whether it came from a
default or from an explicit `< BasicObject`.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H1FEjW6nMpZrWPmeWX9miT
apiology
marked this pull request as ready for review
August 18, 2026 15:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With activesupport in the bundle, Solargraph reports the wrong superclass for
DateTime:DateTimeis then cut off fromDateand from everything above it.The
Objectcomes from activesupport reopening the class:A reopening with no superclass clause asserts nothing about ancestry — and it cannot, because Ruby fixes a class's superclass at its first definition and refuses to let anything restate it differently:
A class with no superclass reference already resolves to
ObjectviaStore#try_special_superclasses, so the mapper now skips recording anObjectreference at all, leaving only the specific one that carries a claim.get_superclassis untouched — it stays a plain.firstwith no tie-break, because there is no longer a conflict to arbitrate.BasicObjectreferences are kept, since the only class YARD defaults toBasicObjectisObjectitself, where the reference is correct either way.Suite: 1625 examples, 0 failures, 60 pending. Opening as a draft.
This PR was written by Claude (Anthropic's Claude Code) on behalf of @apiology.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H1FEjW6nMpZrWPmeWX9miT