Report lint when an extension member name collides with extendee member name #58182
Labels
area-devexp
For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
devexp-linter
Issues with the analyzer's support for the linter package
linter-lint-request
P3
A lower priority bug or feature request
type-enhancement
A request for a change that isn't a bug
Describe the rule you'd like to see implemented
See #41878 and dart-lang/language#966.
Extensions are legally allowed to declare members whose names collide with members declared on the extended class. However, this is often undesirable. A) it is difficult to call the extension member; it can only be called by explicitly using the extension's name. B) it may be accidental; it may be that in some versions of the extended class, there is no collision, and in later versions, there is. If a developer is editing an extension with a member which newly collides with another member, it would be good to know.
Extensions mean that adding a member to a class may be a breaking change for the new reason that code which previously called an extension member would now call this mysterious new member.
Examples
Libraries which import
package_two/b.dart
will get different behavior based on which packagepub
has fetched for their code's.packages
file. Without any static analysis warnings, the author ofpackage_two/b.dart
does not know that their extension member overrides an existing member, when they upgrade their dependency on package_one to include 2.0.The text was updated successfully, but these errors were encountered: