Skip to content

Fix signature lookup through prepended methods - #2706

Open
KaanOzkan wants to merge 1 commit into
mainfrom
ko-fix-prepended-method-signatures
Open

Fix signature lookup through prepended methods#2706
KaanOzkan wants to merge 1 commit into
mainfrom
ko-fix-prepended-method-signatures

Conversation

@KaanOzkan

@KaanOzkan KaanOzkan commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Motivation

Resolves #2705

Implementation

Go upto 2 levels to find a signature from the parent function if we can't find a signature in the original method

Tests

Currently testing it fully on Core, already observed that this particular test case is fixed

@KaanOzkan
KaanOzkan force-pushed the ko-fix-prepended-method-signatures branch 2 times, most recently from f7dbd97 to f141140 Compare August 25, 2026 18:19
Comment on lines +136 to +139
# Looking up the original `Example#foo` evaluates its `sig`. Because `Wrapper`
# was prepended, Ruby now resolves `Example#foo` to `Wrapper#foo`, so Sorbet
# stores the signature for `Wrapper#foo`. The first pass causes the store; the
# second pass finds `Example#foo`'s signature on `Wrapper#foo`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is too hard-coded to the prepend case, but this implementation doesn't do anything to limit to prepended modules (and it's surprisingly difficult to identify them)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a precursor to the comment, wdyt?

Comment thread lib/tapioca/runtime/reflection.rb Outdated
current_method = current_method.super_method
end

return nil if pass.zero? && !T::Utils.signature_for_method(method)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make it faster in the normal case and return early, new version should be easier to understand

@KaanOzkan
KaanOzkan force-pushed the ko-fix-prepended-method-signatures branch from f141140 to dfe8fab Compare August 25, 2026 19:29
@KaanOzkan
KaanOzkan marked this pull request as ready for review August 25, 2026 19:33
@KaanOzkan
KaanOzkan requested a review from a team as a code owner August 25, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepending a module can cause tapioca dsl to produce an untyped signature

2 participants