-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
NNBDIssues related to NNBD ReleaseIssues related to NNBD Releaselegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.
Description
The following program is accepted by the analyzer but rejected by the CFE:
class C {
late final int x = 0;
C(int value) {
x = value;
}
}
main() {
print(C(1).x);
}I believe this is the relevant spec text:
A non-local
latevariable declaration D implicitly induces a getter
into the enclosing scope. It also induces an implicit setter iff one of the
following conditions is satisfied:
- D is non-final.
- D is late, final, and has no initializing expression.
Since the declaration of x is late, final, and has an initializing expression, it meets neither of these conditions, so there should be no implicit setter and the assignment x = value should be illegal.
Metadata
Metadata
Assignees
Labels
NNBDIssues related to NNBD ReleaseIssues related to NNBD Releaselegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.