Closed
Description
import 'dart:async';
void complete_<T>(Completer<T> completer, T value) {
print(T); // prints "Object"
completer.complete(value);
}
void main(List<String> arguments) {
final completer = Completer<int>();
// completer.complete("foo");
// Compilation error:
// error: The argument type 'String' can't be assigned to the parameter type 'FutureOr<int>'. (argument_type_not_assignable at [HelloWorldDart] bin/main.dart:11)
complete_(completer, 'foo');
// Compilation success (no issues)
// Runtime error:
// type 'String' is not a subtype of type 'FutureOr<int>' of 'value'
}
▶ dart --version
Dart VM version: 2.8.4 (stable) (Wed Jun 3 12:26:04 2020 +0200) on "macos_x64"