Open matanlurey opened 6 years ago
There is a similar issue in typedefs, I'm not sure if it has already been brought up:
// The T in Function shadows the T in the name.
MyCallback<T> = Function<T>(T);
// Correct version.
MyCallback2<T> = Function(T);
For example, in 2.0.0-dev.68.0 the following code produces the analyzer error:
A value of type '(String) → void' can't be assigned to a variable of type '<T>(T) → void' at main.dart:7:23 • invalid_assignment
MyCallback<T> = Function<T>(T);
void main() {
MyCallback<String> bar = foo;
}
void foo(String value) {}
@matanlurey I'm not getting a compile error on your snippet of code (2.0.0-dev.69.2).
Lol see https://github.com/dart-lang/sdk/issues/57713 also
@vsmenon Really? I see it internally, in DDC. Unless this was just fixed.
Reproduction case:
This causes a compile-time error:
That's because the
T
's are different...I do not know where to assign this (language? cfe? analyzer?)