Navigation Menu

Skip to content
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

Confusing warning message on assignment to typedefs with type parameters #18840

Closed
justinfagnani opened this issue May 15, 2014 · 7 comments
Closed
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Milestone

Comments

@justinfagnani
Copy link
Contributor

The following code warns that "A value of type 'compare' cannot be assigned to a variable of type 'Comparable'

The warning goes away if you remove the type parameter from the field's annotation.

class A<V> {
  Comparator<V> comparator = Comparable.compare;
}

@bwilkerson
Copy link
Member

I think the warning is actually valid. The static type of the variable is '(V, V) -> int' and the static type of the method is '(Comparable, Comparable) -> int' and those types are not assignable to each other.

But while the warning is valid, the error message is confusing. It should at least contain actual types something like

  A value of type '(Comparable, Comparable) -> int' is not assignable to a variable of type '(V, V) -> int'


Added this to the 1.5 milestone.
Removed Priority-Unassigned label.
Added Priority-Medium, Analyzer-UX labels.

@justinfagnani
Copy link
Contributor Author

Ok, the warning message did confuse me. Changing the type parameter declaration to V extends Comparable<V> fixes the warning too.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the 1.5 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@bwilkerson
Copy link
Member

Removed Oldschool-Milestone-1.6 label.
Changed the title to: "Confusing warning message on assignment to typedefs with type parameters".

@bwilkerson
Copy link
Member

The message has been updated to read "A value of type 'Comparable' cannot be assigned to a variable of type 'V'".


Added Fixed label.

@clayberg
Copy link

Added this to the 1.8 milestone.

@justinfagnani justinfagnani added Type-Defect area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-ux labels Nov 28, 2014
@justinfagnani justinfagnani added this to the 1.8 milestone Nov 28, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

4 participants