Infer function parameter types when overriding the same-named class function in an instance of that class #2859
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.
resolves #2158, #2569 (comment)
The problem
Sometimes we will want to define interface for overriding in instance object of that class, and retain the param types defined in the interface while overriding. But currently no way to do so as described in #2158 and #2569 (comment)
Proposed change
Detailed explanation here: #2569 (comment)
Expected Result
Additional notes
duplicate-set-field
diagnostic is allowing aninstance variable
to override any of itsclass function/method
.i.e. all function/methods from a class can be overriden in variable of that type, without any
duplicate-set-field
warning.i.e. it doesn't work when the namespace is just a global variable ❌
@override
will be definitely needed for that case, as otherwise no way to distinguish between setting duplicate field or really doing override 😕中文版
duplicate-set-field
warningclass/type
variable 組合下的 override 場景 (例子見上邊)@override
語法支持了,否則不能區分是出現 duplicate 還是真的想 override