The following code is currently rejected by flow analysis:
void forEachWithoutDeclLoopVar(Object x) {
if (x is int) {
x.isEven; // Verify that promotion occurred
for (x in [0]) {
x.isEven; // ERROR: `Object` has no method `isEven`
break;
}
}
}
It seems like we should be able to do better than this, because [0] should be inferred as <int>[0], and therefore the implicit assignment to x in the for-each loop should not undo the promotion.
The following code is currently rejected by flow analysis:
It seems like we should be able to do better than this, because
[0]should be inferred as<int>[0], and therefore the implicit assignment toxin the for-each loop should not undo the promotion.