-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
Essentially, an explicit type annotation will always take precedence over an implicitly inferred type. Thus, if you wish a sub-class to narrow an overridden type, you ought to do so explicitly with a type annotation. The only time the child's type will automatically narrow a parent's type is if the parent did not provide an explicit type annotation for the field/method.
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
230b7fb
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.
Would it be similarly feasible to make it so that overriding a variable typed with
MyClass|nil
by MyClass would "get rid" of the nil part for the subsequent usage of that variable?Let's say I have this:
Here the analyzer is a bit confused, because it correctly understands the call and the arguments (hints appear correctly, types are correct, etc.), but it does say
No such member 'doThing' found on type 'nil'
.I'm testing on the latest master btw.
230b7fb
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.
@adriweb This commit is regarding the inferred type of members when inheriting from a base class. Where as it looks like you're after
nil
tracking. There's already an issue fornil
tracking, #4. However, yes that's on my list of features to implement - a few features are ahead of it though.230b7fb
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.