Skip to content

Resolve mixin and superclass references as types - #374

Draft
apiology wants to merge 1 commit into
masterfrom
mixin-references-as-types
Draft

apiology wants to merge 1 commit into
masterfrom
mixin-references-as-types

Conversation

@apiology

Copy link
Copy Markdown
Owner

Claude: This PR was written by Claude Code on behalf of @apiology.

Problem

A literal type argument on an RBS mixin is lost:

module Operating[T]
  def operator: () -> T
end

class Comparer
  # Comparer#operator returns generic<T>, not "<"
  include Operating["<"]
end

Mixin and superclass arguments are joined into strings and parsed back at each lookup, so any argument that does not survive the round trip drops out of method resolution.

This example stays generic<T> until castwide/solargraph#1104 lands, since the RbsTranslator on master turns the literal into undefined first; its spec is pending on that PR.

Solution

Reference pins keep their generic values as ComplexTypes and ApiMap passes types through include, prepend, extend, superclass and included-hook lookups (Constants#dereference_type, Store#superclass_type), so nothing is re-parsed; an include that does not resolve is now skipped instead of being looked up as the root namespace.

Moved out of castwide#1104 to keep that PR reviewable.

RBS mixin and superclass arguments went through strings: conversions
joined them into Reference#generic_values, Reference#type parsed name
and values back, and ApiMap turned each dereferenced reference into a
tag that inner_get_methods parsed again.

Reference#generic_values now holds ComplexTypes and #type builds its
type from them. Constants#dereference_type, Store#superclass_type and
ApiMap#inner_get_methods pass types through include, prepend, extend,
superclass and included-hook lookups; dereference and
qualify_superclass remain as string wrappers for other callers. The
Store superclass cache is removed: its lookup result was discarded
and recomputed on every call.

An include that does not resolve is now skipped rather than looked up
as the root namespace. inner_get_methods_from_reference and
resolve_generics document the nil namespace pin they already accept.

The spec for include Operating["<"] is pending on castwide/solargraph
PR 1104: the YARD-string RbsTranslator on master turns the literal
into undefined before it reaches the reference.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFJrPm9QhVqVqk5QPMD1c6
apiology added a commit that referenced this pull request Oct 29, 2026
Mixin and superclass references resolved as ComplexTypes is separate
from this PR's docstring work, so it now lives in its own PR:
#374

This reverts commit 5dd774b.
This reverts commit 7777ace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant