Fix method signatures being overwritten by prepended modules - #2718
Open
DaneHarrison wants to merge 3 commits into
Open
DaneHarrison wants to merge 3 commits into
DaneHarrison wants to merge 3 commits into
Conversation
Author
|
I have signed the CLA! |
DaneHarrison
marked this pull request as draft
September 18, 2026 18:41
DaneHarrison
marked this pull request as ready for review
September 19, 2026 05:14
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.
Motivation
Fixes #2072 - When a module is prepended onto a class, Tapioca generates the RBI using the prepended module's signature instead of its own.
Implementation
compile_methodreceives methods obtained withModule#instance_method, which follows the ancestor chain. When amodule is prepended to a class and defines the method,
instance_methodreturns the prepended module'sUnboundMethodrather than the class's own, socompile_methodwas compiling the wrong method.method_owned_by_constant?becomesmethod_defined_by_constant. It walkssuper_methodand returns the method theconstant itself defines.
New
signature_defined_by_constantreturns the signature declared on that method. A signature is only acceptedif
signature.method.ownermatches the method's owner.The attr_accessor writer inference resolves the constant's own reader first, so it works in either evaluation order.
Further Considerations:
signature_ofi.e underdsl, I suspect those will need to be updated as wellTests