Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
leafpetersen opened this issue Nov 24, 2015 · 2 comments
Open
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. customer-flutter devexp-ux P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@leafpetersen
Copy link
Member

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);
}
@leafpetersen leafpetersen added the legacy-area-analyzer Use area-devexp instead. label Nov 24, 2015
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@mraleph
Copy link
Member

mraleph commented Jun 26, 2018

This is not limited to generic instantiations. Analyzer does not seem to disambiguate parameter types in closures which is very confusing to users.

@mraleph mraleph changed the title Analyzer doesn't disambiguate type names in generic instantiations Analyzer doesn't disambiguate type names in function parameter types Jun 26, 2018
@srawlins
Copy link
Member

I think we still have this problem. CFE has greatly improved their text w.r.t. this issue.

@srawlins srawlins added P3 A lower priority bug or feature request and removed P2 A bug or feature request we're likely to work on labels Apr 13, 2023
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. customer-flutter devexp-ux P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants