Repository navigation
Conversation
An undocumented method in a module, such as solid_queue's
ActiveJob::BatchId#serialize (`super.tap { ... }`), typed as undefined
even when the class including the module inherits a documented method
of the same name. Pin::Method#typify_from_super can only search the
module's own ancestors, which never contain the including class's
superclass, and call inference takes the first pin of the class's
method stack, so `ActiveJob::Base.new.serialize` was undefined too.
castwide#1378 made this visible by mapping explicit-receiver includes such as
`ActiveJob::Base.include ActiveJob::BatchId`, which put BatchId's
method first in ActiveJob::Base's stack; an inline `include` inside the
class body had the same gap before it.
ApiMap#get_methods now gives such a module method the type of the
nearest later method of the same name in the class's ancestry, using
Pin::Base#proxy. It runs in get_methods rather than get_method_stack
because callers like solargraph-rails' definition specs typify the
pins get_methods returns.
A nearest later pin at the same path (the same method from another
source) blocks the proxy: taking an RBS `void` for
SchemaStatements#create_table that way lost the block parameter type
in migrations. A later type with unresolved generics is skipped too,
since another namespace's type parameters leaked into ActiveRecord
finder methods otherwise.
Owner
Author
|
Claude: Closing: failure B (ActiveJob#logger) is fixed by castwide#1446 instead, so this approach is no longer needed. |
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.
Claude: This PR was written by Claude Code on behalf of @apiology.
Problem:
An undocumented module method that overrides a documented one loses its type:
Since castwide#1378 maps explicit-receiver includes like solid_queue's
ActiveJob::Base.include ActiveJob::BatchId,ActiveJob::Base#serializenow infersundefinedinstead ofHash{String => undefined}.Solution:
ApiMap#get_methodsgives such a module method the type of the nearest later method of the same name in the including class's ancestry, since the module's own ancestors never contain that method.It skips a later pin at the same path (the same method from another source) and types with unresolved generics. It works in
get_methodsrather thanget_method_stackbecause callers such as solargraph-rails' definition specs typify the pinsget_methodsreturns.Test plan:
rails_spec.rb(with [regression fix] Map mattr, cattr and config_accessor accessors castwide/solargraph#1403 and [regression fix] Let conventions add source paths when mapping gems castwide/solargraph#1404):BatchId#serializepasses; eight module methods elsewhere change fromundefinedto a type, so four definition files there need updating.