[RFC] Warn if deprecated function is referred #1011
Closed
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.
This diff implements the last missing feature for deprecation warnings (#376): to warn when the deprecated function is referred (e.g. passed as function reference).
The implementation checks when typechecking an expression, whether the type of an expression is a deprecated function/bound method. If that's the case, a deprecated warning is generated.
If we only add this check, we might run into the issue that a deprecated function call would generate 2 deprecation warnings, one when the function is typechecked, and another when the call is typechecked.
To avoid the duplication, we avoid emitting the deprecation warning when typechecking a function call, instead we emit the deprecation warning when generating the call target.
As a consequence, the error message of deprecation warning is changed from "Calling" a deprecated function to "Reference to" a deprecated function. Suggestions are welcome for how to improve clarify of this error message.