Skip to content

Apply every overload of an override - #497

Closed
apiology wants to merge 1 commit into
masterfrom
apply-every-override-overload
Closed

apiology wants to merge 1 commit into
masterfrom
apply-every-override-overload

Conversation

@apiology

Copy link
Copy Markdown
Owner

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

Problem

An @!override with several @overload tags keeps only the first one:

class Klass
  def m(*args); end
end

# @!override Klass#m
#   @overload m(one)
#     @return [Array]
#   @overload m(one, two, *more)
#     @return [Array<Array>]

# Inferred ["Array"], expected ["Array", "Array<Array>"]
Klass.new.m(:a, :b)

solargraph-rails declares ActiveRecord::Calculations#pluck this way, so its Rails 7.0 definitions spec fails against current Solargraph.

Solution

Add all of an override tags before rebuilding the method signatures from its docstring, and clear signatures cached from the docstring first, so an earlier inspect or reset_generated! can no longer lock in the first overload.

ApiMap::Index#map_overrides added an override tag by tag and called
reset_generated! after each. Pin::Method#reset_generated! reads
#signatures, which caches the signatures and overloads built from the
docstring as it stood, so only the first @overload took effect. The
@!override of ActiveRecord::Calculations#pluck in solargraph-rails
thus typed pluck as Array alone on Rails 7.0 and 7.1.

The same caching happened earlier whenever anything read the pin
signatures before the override was applied, such as the debug log in
map_overrides inspecting the pins.

Add all of the override tags before regenerating anything, and have
Pin::Method#reset_docstring_signatures! drop the overloads,
signatures and return type generated from the docstring, keeping
ones that were passed in or assigned.
@apiology
apiology marked this pull request as ready for review November 16, 2026 21:33
@apiology

Copy link
Copy Markdown
Owner Author

Claude: Closing as covered by castwide/solargraph#1104, which applies every @!override overload; calls infer the same types on both.

@apiology apiology closed this Nov 18, 2026
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