Closed iarkh closed 4 years ago
IT should not fail. The bound of T
in testGenericFutureOr
is FutureOr<dynamic>
(or FutureOr<Object?>
, I don't remember exactly where that landed, but it doesn't matter here).
The Null
type is a subtype of that and should be accepted.
It seems to be a runtime problem.
Maybe this is related to the current encoding of FutureOr
types in kernel: https://github.com/dart-lang/sdk/issues/40123
Dart VM version: 2.8.0-edge.40f23c735f04433e4fc334fbd674474bd3de0f8b (Tue Jan 28 01:14:48 2020 +0000) on "linux_x64"
NNBD Spec reads that FutureOr is nullable type.
Please try to run the following code:
Analyzer passes with this. Dart throws unexpected runtime error on the
testGenericFutureOr<Null>();
line.Seems like dart should pass here too. Or, if something was changed and
FutureOr
is non-nullable, it should throw compile error instead.Sample output is: