Files
sdk/tests/language/final/initializer_instance_reference_test.dart
T
Johnni Winther 3f158dcd71 [cfe] Merge Resolver.buildFieldInitializer1/2
This update computation of implicit field types to return the inferred initializer. The ensure that we only compute the initializer once, and allows us to merge two pipelines for compute the field type and initializer.

Change-Id: I6005e19cc3dec9c717e426f06d817e2d45edcff1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451480
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-09-29 03:53:53 -07:00

23 lines
677 B
Dart

// Copyright (c) 2016, 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.
// Dart2js regression test. Error in initializer might be report with the wrong
// current element.
class C {
const C();
// [error column 3, length 5]
// [analyzer] COMPILE_TIME_ERROR.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST
final x = 1;
final y = x;
// ^
// [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
// [cfe] Can't access 'this' in a field initializer to read 'x'.
}
main() {
const C().y;
}