Skip to content

[Extension types] diagnostic when implementing a class with a conflicting member #53567

Closed
@pq

Description

@pq

Consider the following:

extension type E(C c) implements C {}

class C {
  void c() {}
}

Can you spot the problem?

The issue becomes apparent when you try and invoke c():

void main() {
  E e = E(C());
  e.c();
}

and you see an invocation_of_non_function_expression diagnostic.

Potentially I see two possible improvements:

  1. a warning on E, nudging you to rename c to not collide with void c(), and
  2. an improved message on the invocation of .c()

(For 2, I'm thinking something more like how we report field and method conflicts CONFLICTING_FIELD_AND_METHOD.)

/cc @bwilkerson @scheglov @srawlins @dart-lang/language-team

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondevexp-warningIssues with the analyzer's Warning codesfeature-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