Files
sdk/tests/language/compile_time_constant/compile_time_constant_test.dart
T
Robert Nystrom 959bf6e1c3 Migrate language_2/compile_time_constant to NNBD.
Change-Id: I6cbad15f7151a1a5e1ece71f91ddfb826dca5de5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141762
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2020-03-31 15:51:50 +00:00

30 lines
814 B
Dart

// Copyright (c) 2012, 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.
class Bad {
int foo = 0;
final int bar =
foo
// ^^^
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
// [cfe] Can't access 'this' in a field initializer to read 'foo'.
-1;
static const int toto =
bar
// ^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
// [cfe] Can't access 'this' in a field initializer to read 'bar'.
// ^^^
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
// [cfe] Getter not found: 'bar'.
-3;
}
void use(x) {}
main() {
use(new Bad().bar);
use(Bad.toto);
}