-
Notifications
You must be signed in to change notification settings - Fork 224
Closed
Description
After having dealt with late
for a long time now and finding the two different aspects of the late
modifier to be convoluted (see #1100 and #1101), I totally expected constructor initialization to not be lazy. But why is that?
You can find a more detailed version of the question and code here.
class Baz {
Baz(
// Implicit assignment by the caller.
this.assignmentInConstructor,
) : assignmentInInitializerList = calculate() {
assignmentInConstructorBody = calculate();
}
late final int assignmentInConstructor; // I expect this to be lazily initialized.
late final int assignmentInInitializerList; // I expect this to also be lazily initialized.
late final int assignmentInConstructorBody; // I expect this to not be lazily initialized.
}
None of the instance fields are lazily initialized. I included what I thought to be the intuitive though of someone who knows constructors but has not dealt with late
yet.
Metadata
Metadata
Assignees
Labels
No labels