Files
sdk/tests/language/static/final_field2_test.dart
T
Konstantin Shcheglov af110a7aa4 Change resolution of assignment to PropertyAccess.
Change-Id: Ie9de1166eb0dfd179d539f1b10c54084caf643d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162248
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-11 15:50:20 +00:00

29 lines
676 B
Dart

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Disallow re-assignment of a final static variable.
class A {
static const x = 1;
}
class B {
const B() : n = 5;
final n;
static const a;
// ^
// [analyzer] COMPILE_TIME_ERROR.CONST_NOT_INITIALIZED
// [cfe] The const variable 'a' must be initialized.
static const b = 3 + 5;
}
main() {
A.x = 2;
// ^
// [analyzer] COMPILE_TIME_ERROR.ASSIGNMENT_TO_CONST
// [cfe] Setter not found: 'x'.
new B();
print(B.b);
print(B.a);
}