76ed8441b9
Change-Id: I718ba69d31d44f30bb52157e87ebc64316bf860b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193586 Commit-Queue: Mayank Patke <fishythefish@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Stephen Adams <sra@google.com>
42 lines
832 B
Dart
42 lines
832 B
Dart
// Copyright (c) 2021, 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.
|
|
|
|
void main() {
|
|
testUninitializedNonFinalInstanceField();
|
|
testUninitializedFinalInstanceField();
|
|
testInitializedNonFinalInstanceField();
|
|
testInitializedFinalInstanceField();
|
|
}
|
|
|
|
class C {
|
|
late int a;
|
|
late final int b;
|
|
late int c = -1;
|
|
late final int d = -1;
|
|
}
|
|
|
|
var c = C();
|
|
|
|
void testUninitializedNonFinalInstanceField() {
|
|
print(c.a);
|
|
c.a = 42;
|
|
print(c.a);
|
|
}
|
|
|
|
void testUninitializedFinalInstanceField() {
|
|
print(c.b);
|
|
c.b = 42;
|
|
print(c.b);
|
|
}
|
|
|
|
void testInitializedNonFinalInstanceField() {
|
|
print(c.c);
|
|
c.c = 42;
|
|
print(c.c);
|
|
}
|
|
|
|
void testInitializedFinalInstanceField() {
|
|
print(c.d);
|
|
}
|