Open leafpetersen opened 2 years ago
We apply following rules when gathering constraints here in the analyzer:
String?
vs FutureOr<T>?
- If
Q
isQ0?
the match holds under constraint setC
:
- If
P
isP0?
andP0
is a subtype match forQ0
under constraint setC
.
String
vs FutureOr<T>
- If
Q
isFutureOr<Q0>
the match holds under constraint setC
:
- Or if
P
is a subtype match forQ0
under constraint setC
.
String
vs T
.
cc @chloestefantsova
This does suck extra because the parameter to Future.value
is optional and nullable, and it's not part of the type system that you must only pass null
when the type argument is nullable.
(We should fix that!)
The following code is inferred inconsistently between the CFE and the analyzer:
The analyzer emits no error, suggesting that inference is inferring
String
for the type argument toFuture.value
, whereas the CFE emits the following error:I believe the analyzer behavior here is in general more useful, I'm not sure off hand which is consistent with the spec. cc @stereotype441 @eernstg @johnniwinther @scheglov