Open whesse opened 2 years ago
Looking at the generated code, I find this:
isSentinel(value) {
return false;
},
and that seems to make the logic around the late final variable go wrong: The variable lateFinalMap
is considered initialized even though it isn't.
get$lateFinalMap() {
var t1, result,
value = this.__Foo_lateFinalMap_FI;
if (A.boolConversionCheck(A.isSentinel(value))) {
t1 = type$.String;
result = A.LinkedHashMap_LinkedHashMap$_empty(t1, t1);
this.__Foo_lateFinalMap_FI !== $ && A.throwLateFieldADI("lateFinalMap");
this.set$__Foo_lateFinalMap_FI(result);
value = result;
}
return value;
},
(Edit: I got the example from a different place, the variable was declared as late final lateFinalMap = <String, String>{};
in the example I compiled.)
This is failing due to --disable-type-inference
. See #48312 for a similar issue - I closed that one since some improvements we landed happened to fix it, but I can start digging into the root cause.
A class with a late member, declared with an initializer, fails to get initialized when accessed if the program is compiled with dart2js optimization level 0.
The initialization is carried out correctly at higher optimization levels.
The command
creates a compiled program that fails on Chrome, with the exception:
on the program
The error is present on the stable branch, and on current tip-of-tree 2.19.0-59.0.dev.