Skip to content

[analyzer] [extension types] Implement 'precludes' rule to eliminate method/setter conflicts #53719

Closed
@eernstg

Description

@eernstg

Edit, Nov 24 2023: This issue has been retargeted, and it is no longer about improving the diagnostic message for a certain method/setter conflict. Instead, the language was modified such that those conflicts do not exist any more, and this issue is now the implementation issue for the new rules.

As such, this is now the analyzer specific issue for #53717.


This is the analyzer specific issue for #53717. Consider the following example:

extension type E1(int i) {
  set m(_) {}
}

extension type E2(int i) implements E1 {
  void m() {}
}

void main() {
  E2(1).m = 10;
}

The analyzer reports the following error for the example, which is from #53717:

Class 'E2' can't define method 'm' and have field 'E1.m' with the same name.

This is confusing because there are no instance variable declarations named m anywhere in this program. It would probably be helpful to report something like "Class 'E2' can't define method 'm' and have a setter 'E1.m' with the same name".

(The language specification documents would say that the name of the setter is m= rather than m, but presumably the analyzer error messages consider setters to have names like m in general, without the =.)

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondart-model-analyzer-specIssues with the analyzer's implementation of the language specfeature-extension-typesImplementation of the extension type featurelegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions