Skip to content

Confusing reference to inheritance in error message about member conflict #34274

Closed
@eernstg

Description

@eernstg

Consider the following test (excerpt from co19 test Language/Classes/Instance_Methods/same_name_setter_t01.dart):

class C {
  foo() {}
  set foo(var a) {}
}

main() {
  C c=new C();
  c.foo();
//    c.foo=1;
}

With dart2js (I'm using area-front-end because I assume that the behavior is predominantly determined in the front end), we get the following response:

Language/Classes/Instance_Methods/same_name_setter_t01.dart:16:3:
Error: Can't declare a member that conflicts with an inherited one.
  foo() {}
  ^
Language/Classes/Instance_Methods/same_name_setter_t01.dart:17:7:
Info: This is the inherited member.
  set foo(var a) {}
      ^
Error: Compilation failed.

It is correct to flag the given situation as an error, but it is confusing to claim that there is any involvement of inheritance: The two conflicting members are both declared in C, and the only superclass relationship is the one to Object, and Object has no member whose basename is foo.

So I believe that the given error message should avoid mentioning inheritance in this situation.

PS: This comment of #21201 says 'This is indeed fixed with the unified frontend', and this issue basically says "Not quite!", in the sense that the error is flagged, but the error message is misleading. It might be useful to check out what was done for #21201 when fixing this issue, because it should be concerned with the same parts of the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onimprove-diagnosticsRelated to the quality of diagnostic messageslegacy-area-front-endLegacy: Use area-dart-model instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions