Files
sdk/tests/language/variable/inst_field_initializer1_test.dart
2021-05-09 18:51:18 +00:00

18 lines
536 B
Dart

// Copyright (c) 2019, 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.
/// Catch illegal access to 'this' in initialized instance fields.
class A {
var x = 5;
var arr = [x]; // Illegal access to 'this'.
// ^
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
// [cfe] Can't access 'this' in a field initializer to read 'x'.
}
void main() {
A();
}