You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[warning] x (dynamic) will need runtime check to cast to type List<String> (/Users/leafp/tmp/scratch.dart, line 4, col 20)
Suggesting that we are not successfully inferring the generic type parameters for fold. I would have thought we would be catching this. I don't think this is an instance of #25490, but maybe an interaction between the upwards inference on the arguments and the downwards inference on the closure parameter?
voidmain() {
List<int> o;
var x = o.fold(0, (x, y) => x + y);
List<String> y = x;
}
The text was updated successfully, but these errors were encountered:
info: [INFERRED_TYPE_CLOSURE] line 12, column 29 of /main.dart: (x, y) => x + y has inferred type (dynamic, int) → dynamic
var x = o.fold(0, (x, y) => x + y);
^^^^^^^^^^^^^^^
info: [DYNAMIC_INVOKE] line 12, column 39 of /main.dart: x + y requires dynamic invoke
var x = o.fold(0, (x, y) => x + y);
^^^^^
I believe what happens is:
We instantiate with T as dynamic.
That pushes down (dynamic, int) → dynamic to the closure.
When we come back up, we see that type as the 2nd arg to fold. LUB of "int" and "dynamic" will be "dynamic"
So I think we need #25490, unless I'm missing something.
If there's some way we could infer from only the first argument, we'd get T:int, but we'd still need to push that type down to the lambda, right? At least for checking. Otherwise I don't see how we know that the '+' is a valid operation.
The code below produces the following error:
Suggesting that we are not successfully inferring the generic type parameters for
fold
. I would have thought we would be catching this. I don't think this is an instance of #25490, but maybe an interaction between the upwards inference on the arguments and the downwards inference on the closure parameter?The text was updated successfully, but these errors were encountered: