Skip to content

Analyzer doesn't disambiguate type names in function parameter types #25036

Open
@leafpetersen

Description

@leafpetersen

Analyzing the example program given below produces the following confusing error message:

[warning] The argument type '(Animal) → Animal' cannot be assigned to the parameter type '(Animal) → dynamic' (/Users/leafp/tmp/repo/bug_repo-master/sdk25018/test/lib2.dart, line 9, col 9)

Note that the Animal in the first type is the version from lib2.dart and the Animal in the second type is the version from lib1.dart, but nothing in the error message helps with the disambiguation.

Tested with dartanalyzer version 1.14.0-edge.26b0b1089f465de787502a8cb74e5bc9e215f9bc .

Reproduction case is a simplified version of #25018. Related to #23492 .

lib1.dart

library lib1;
class Animal {}

lib2.dart

library lib2;

import 'lib1.dart' as lib1;

class Animal {}

void main () {
  List<lib1.Animal> l = <lib1.Animal>[];
  l.map((Animal x) => x);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.customer-flutterdevexp-uxtype-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