-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aliasing .new
doesn't reuse the signature from #initialize
#2222
Comments
What do you mean by signature in this case? |
The method signature? Tapioca doesn't generate a signature for I'm not too familiar with # UnboundMethod method -> UnboundMethod?
def fallback(method) # there's most likely a better name for this?
return unless method.source_location.nil?
return unless method.original_name == :new
initialize = method.receiver.instance_method(:initialize)
return if initialize.source_location.nil?
initialize
end
# in Tapioca::Gem::Listeners::Methods#compile_method
parameters = T.let(fallback(method) || method).parameters, T::Array[[Symbol, T.nilable(Symbol)]])
# in Tapioca::Gem::Listeners::SourceLocation#on_method
file, line = (fallback(event.method) || event.method).source_location |
In Tapioca and static typing context signature usually means Yes we can special case I don't think this is a feature we'll prioritize but if you want to explore this feel free to go ahead. |
I'm running into this with the
money
gem:Also note that no
source://
pointer comment is generated for the.new
alias.I get that technically you could override both
.new
and#initialize
to have different signatures, but I'd be surprised if that's a common pattern. AFAICT Sorbet uses#initialize
's signature to validate calls to.new
.The text was updated successfully, but these errors were encountered: