-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
augmentationsIssues related to the augmentations proposal.Issues related to the augmentations proposal.
Description
The language says that the initializers for instance fields run in the order their declarations appear:
int i = 0;
class C {
int a = i++;
int b = i++;
}
main() {
var c = C();
print('${c.a} ${c.b}');
}This prints 0 1.
Now consider:
int i = 0;
class C {}
augment class C {
int a = i++;
}
augment class C {
int b = i++;
}Does it behave the same? Consider that these augmentations may be in separate part files.
I think the obvious answer is that field initializers run in augmentation application order. Or, said another way, applying an augmentation appends new members to a type. That's consistent with how enum values and mixin with clauses are handled.
I don't think there's anything scary here, the proposal just needs to actually specify this.
Metadata
Metadata
Assignees
Labels
augmentationsIssues related to the augmentations proposal.Issues related to the augmentations proposal.