Skip to content

Keep block parameter types documented by @!parse stubs - #94

Merged
apiology merged 2 commits into
fix-1286-generic-cross-file-parsefrom
combine-block-yield-signatures
Sep 8, 2026
Merged

Keep block parameter types documented by @!parse stubs#94
apiology merged 2 commits into
fix-1286-generic-cross-file-parsefrom
combine-block-yield-signatures

Conversation

@apiology

@apiology apiology commented Sep 8, 2026

Copy link
Copy Markdown
Owner

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

Based on castwide#1288.

A workspace @!parse stub's block parameter type has no effect when the
gem's own doc already declares a return type:

module Widgetbox
  class << self
    # @return [String]
    def build(&block) = 'x'
  end
end

# @!parse
#   module Widgetbox
#     class << self
#       # @yieldparam config [String]
#       # @return [String]
#       def build(&block); end
#     end
#   end

Widgetbox.build { |config| config.upcase } # Unresolved call to upcase

The method pin itself carries only one of the two signatures, so hover
and completion lose the same information inference does.

combine_signatures_by_type_arity buckets signatures by type_arity
before merging, and a block's declared-parameter count changes that
bucket, so this adds a pass that merges block-informativeness-only
differences first and makes Callable#combine_blocks prefer the more
informative block instead of choosing arbitrarily; two related gaps stay
open (a stub missing @return is discarded wholesale by
combine_signatures, and def self.build paired with class << self
never combines pins at all).

A gem's plain &block signature and a workspace @!parse stub's
yield-typed one only differ in the block's own type_arity, so
combine_signatures_by_type_arity bucketed them as separate overloads
and left picking between them to Chain::Call at every call site.

Merge them into one signature before that bucketing instead, and
make Callable#combine_blocks prefer the block that actually declares
parameters rather than choosing arbitrarily. The merged pin is now
correct on its own - hover and completion benefit too, not just
inference at a call that happens to trigger dispatch_order.
The merge only fired when one side's block declared zero yielded
parameters. A block documenting one parameter and a sibling
documenting two hit the identical type_arity mismatch and still
failed to combine. Compare declared parameter counts instead of
emptiness, so any side with fewer yielded parameters loses to one
with more, not just the zero case.
@apiology
apiology merged commit 5e40c80 into fix-1286-generic-cross-file-parse Sep 8, 2026
28 checks passed
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