Skip to content

No warnings in extension declarations, when there are member name collisions #41878

Closed

Description

@jwren

See this code:

extension FileSystemEntityExtension on FileSystemEntity {
// method name collision with the path field:
String path() {
return '';
}

// name collision with the method:
bool get existsSync => false;
}

What's also confusing here is that the analyzer navigation and completion ignores them:

f(FileSystemEntity entity) {
  entity.path; //  <-- completes and navigates to lib/io/file_system_entity.dart
  entity.existsSync(); // <-- here too
}

@bwilkerson @scheglov

Activity

  1. added
    devexp-serverIssues related to some aspect of the analysis server
    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)
    on May 12, 2020
  2. bwilkerson commented on May 12, 2020

    @bwilkerson
    Member

    I think this is WAI.

    When resolving a member m against a type T, we first look in the type T and its supertypes for a definition of m. If one is found, we stop. If no member with that name is found, then we look for an extension. So the fact that it's resolving to the members in the class is correct.

    The reason there's no diagnostic when colliding is (IIRC) because those members are still accessible via an extension override such as FileSystemEntityExtension(entity).path.

  3. scheglov commented on May 12, 2020

    @scheglov
    Contributor

    Yes, I agree that this WAI.

    But as Brian mentioned in a CL, we might want to produce a hint on declared extension members if the extended type already declares a member with the same name.

  4. srawlins commented on Jun 7, 2020

    @srawlins
    Member

    I've requested this lint at #58182. I think this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

devexp-serverIssues related to some aspect of the analysis serverlegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions