Open parlough opened 10 months ago
Similarly, the InitLateFinalInstanceFieldStub
is generated/used when accessing a top-level or static final field that is initialized to a const
instantiation in the initialization expression.
class Test {
static final Test instance = const Test(144);
final int value;
const Test(this.value);
}
final Test otherInstance = const Test(144);
void main() {
print(Test.instance.value);
print(otherInstance.value);
}
A snippet like the following where the
late final
field is assigned in the declaration to a potentially constant expression ends up using aInitLateFinalInstanceFieldStub
. There might be intricacies I'm missing, but can't accessing this field be treated as if accessing the constant value?