Prefer generic superclass reference in get_superclass - #73
Open
apiology wants to merge 1 commit into
Open
Conversation
apiology
force-pushed
the
fix-reference-superclass-generic-values
branch
from
September 7, 2026 00:20
db212e4 to
9d9d12e
Compare
apiology
marked this pull request as ready for review
September 7, 2026 02:05
A class documented in both YARD (plain Ruby source, generic args
unparseable) and RBS (e.g. `class Sub[T] < Base[T]`) gets two
Reference::Superclass pins for the same fqns, since GemPins.combine
only merges Method/Namespace pins, not references. get_superclass
took .first, which is whichever pin was indexed first - often the
YARD one, with generic_values always empty.
Prefer a pin that actually carries generic_values when one exists.
Also guards the Hash#[] lookup against nil: superclass_references
is built with a default-proc Hash.new { |h, k| h[k] = [] }, so it
never returns nil at runtime, but RBS's static Hash#[] signature
doesn't reflect that, and Solargraph's own self-typecheck flagged
the resulting Array<Pin::Reference::Superclass>, nil as a real gap
on this line.
apiology
force-pushed
the
fix-reference-superclass-generic-values
branch
from
September 7, 2026 02:05
9d9d12e to
4afc160
Compare
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.
Problem:
get_superclasstakes.firston a class's superclass reference pins, with no preference for one that actually carries generic args over one that doesn't.A class documented in both YARD (plain Ruby source, generic args unparseable) and RBS (
class Sub[T] < Base[T]) gets two separateReference::Superclasspins for the same fqns -GemPins.combinemergesMethod/Namespacepins, but not references. Whichever pin was indexed first wins, which is often the YARD one:Solution: Prefer a pin with non-empty
generic_valueswhen one exists among the candidates, falling back to.firstotherwise.Base branch is #71 (
fix-gempins-combine-namespace-generics), not master - this fix depends on that one'sNamespacemerge to have a non-empty-generics RBS pin to prefer in the first place. It also doesn't fully resolvetl:pr-1329-follow-onin plate-spinner on its own; a further gap remains in substituting a receiver's own generic args into an ancestor's type parameters, not yet root-caused.This PR was written by Claude Code on behalf of @apiology.