sdk
sdk copied to clipboard
@Deprecated should warn if you're overriding a deprecated method
Consider the following code:
class Foo {
@protected
@Deprecated('Do not override this; override betterFoo() instead.')
void foo() {}
@protected
void betterFoo() {}
}
class Bar extends Foo {
@override
void foo() {}
}
The fact that Bar is overriding a deprecated method does not trigger an analyzer hint code (the closest hint code that exists is DEPRECATED_MEMBER_USE, but that's for call-sites, not override-sites). This makes it almost impossible for classes to deprecate protected APIs and get subclasses to migrate away from extending the deprecated API.
We should add a new hint code, DEPRECATED_OVERRIDE, to cover this case.