Open
Description
If you write code like the following:
void foo() {
String s1 = bar(0); // <-- invalid_assignment
String s2 = baz(0); // <-- argument_type_not_assignable
}
num bar(num n) => n;
T baz<T extends num?>(T t) => t;
At bar(0)
you get the following message:
A value of type 'num' can't be assigned to a variable of type 'String'.
Try changing the type of the variable, or casting the right-hand type to 'String'.
At 0
(inside baz
) you get the following message:
The argument type 'int' can't be assigned to the parameter type 'Never'.
In cases with final
/sealed
types (like String
and num
) couldn't we calculate up to invalid_assignment
instead of calculating the generics to Never
(we could still do that but it would be a bit counter intuitive)?
Edit
Found this in a code that simply returned T
without any parameter (it would look somewhere else for the value) and then the problem was happening inside when the return was happening.