Closed
Description
- Dart SDK Version
Dart SDK version: 2.12.0 (stable) (Thu Feb 25 19:50:53 2021 +0100) on "macos_x64"
- MacOSX
In this code the compiler/analyzer does not recognize that foo inside Boo is Foo<String>
void main() {
var boo = Boo(FooStringer((String val) => print(val)));
// boo.foo.call('5'); // this works
boo.call('5');
}
class Foo<V> {
final void Function(V) call;
Foo(this.call);
}
class FooStringer extends Foo<String> {
FooStringer(void Function(String val) callback) : super(callback);
}
class Boo<T extends Foo<V>, V> {
final T foo;
void call(V val) => foo.call(val);
Boo(this.foo);
}
throws type '(String) => void' is not a subtype of type '(dynamic) => void'
changing Boo
to this throws the same error
void main() {
var boo = Boo(FooStringer((String val) => print(val)));
// boo.foo.call('5'); // this works
boo.call('5');
}
class Foo<V> {
final void Function(V) call;
Foo(this.call);
}
class FooStringer extends Foo<String> {
FooStringer(void Function(String val) callback) : super(callback);
}
class Boo<T extends Foo> {
final T foo;
void call(String val) => foo.call(val);
Boo(this.foo);
}