-
Notifications
You must be signed in to change notification settings - Fork 172
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
Infer types for method calls on immediately instantiated objects #3007
Infer types for method calls on immediately instantiated objects #3007
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice enhancement. Can we also make a note of this in the docs to help users understand why completions may or may not be available.
@andyw8 a note of what exactly? How we infer the type for |
I'm thinking something like:
|
797cab1
to
da24be0
Compare
Note is good, LGTM. |
da24be0
to
2241ced
Compare
Merge activity
|
Motivation
Closes #2994
This PR adds inference for methods invoked directly on an object instantiation. It's fairly easy to add, so I think it's worth getting it done.
Implementation
When the receiver of a method call is another method call using
new
, we infer the type of the constant receiver and then return the attached version of it. For example:The only exception is if the method
new
was overridden, which is valid in Ruby. We cannot guarantee that the override actually returns a new object of the class, so it's better to not infer anything in those cases.Automated Tests
Added tests.