d352bc28b8
Since the flag is now enabled by default, there should be no mention of it. There are still some uses in front_end/testcases that are not just removable (it also uses `no-non-nullable`). There migth be more uses that are not as easily found as grepping for `--enable-experiment Removes two VM tests where fixing them meant they were just duplicating the corresponding non *_2/ tests. Fixes #44941 TEST= Large number of tests chaged.=(no-)?non-nullable`. Change-Id: Ief755981ccde9a5482fcdf408c2929c74433a710 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183688 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
62 lines
1.8 KiB
Dart
62 lines
1.8 KiB
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.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
int initCalls = 0;
|
|
double init() {
|
|
++initCalls;
|
|
return 1.23;
|
|
}
|
|
|
|
class A {
|
|
late double? fieldWithInit = init();
|
|
late double fieldWithTrivialInit = 1.23;
|
|
late double? fieldWithNullInit = null;
|
|
late double fieldWithNoInit;
|
|
}
|
|
|
|
main() {
|
|
// Late, non-final, with init.
|
|
var a = A();
|
|
Expect.equals(0, initCalls);
|
|
Expect.equals(1.23, a.fieldWithInit);
|
|
Expect.equals(1.23, a.fieldWithTrivialInit);
|
|
Expect.equals(null, a.fieldWithNullInit);
|
|
Expect.throws<Error>(() => a.fieldWithNoInit);
|
|
Expect.equals(1, initCalls);
|
|
Expect.equals(1.23, a.fieldWithInit);
|
|
Expect.equals(1.23, a.fieldWithTrivialInit);
|
|
Expect.equals(null, a.fieldWithNullInit);
|
|
Expect.throws<Error>(() => a.fieldWithNoInit);
|
|
Expect.equals(1, initCalls);
|
|
a.fieldWithInit = 4.56;
|
|
a.fieldWithTrivialInit = 4.56;
|
|
a.fieldWithNullInit = 4.56;
|
|
a.fieldWithNoInit = 4.56;
|
|
Expect.equals(1, initCalls);
|
|
Expect.equals(4.56, a.fieldWithInit);
|
|
Expect.equals(4.56, a.fieldWithTrivialInit);
|
|
Expect.equals(4.56, a.fieldWithNullInit);
|
|
Expect.equals(4.56, a.fieldWithNoInit);
|
|
Expect.equals(1, initCalls);
|
|
initCalls = 0;
|
|
|
|
// Late, non-final, with init that's pre-empted by setter.
|
|
var b = A();
|
|
Expect.equals(0, initCalls);
|
|
b.fieldWithInit = 4.56;
|
|
Expect.equals(0, initCalls);
|
|
Expect.equals(4.56, b.fieldWithInit);
|
|
Expect.equals(0, initCalls);
|
|
|
|
// Late, non-final, with init that's pre-empted by null setter.
|
|
var c = A();
|
|
Expect.equals(0, initCalls);
|
|
c.fieldWithInit = null;
|
|
Expect.equals(0, initCalls);
|
|
Expect.equals(null, c.fieldWithInit);
|
|
Expect.equals(0, initCalls);
|
|
}
|