ef8cc2c1cf
As per planned breaking change to let platforms decide how they and what throw for late initiaization errors, we no longer need a public `LateInitializationError` class. It's confusing to have one if some platforms throw something else instead. Removes the public abstract class. The dart:_internal implementation class `LateError` no longer implements it. This is the only implementation of the public interface, and the class which platforms either throw directly, or through front-end lowering of the feature. Remove mentions in tests. All tests now just expect `Error`, some platform specific tests might test the message. TEST=rewrote tests referring to LateInitializationError. Change-Id: I54344a67f89ce101ed770412db134e12354cdcc4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174928 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
main(List<String> args) {
|
|
late int Function() recursiveInitLocal;
|
|
late final int local = recursiveInitLocal();
|
|
|
|
bool doRecursiveInitLocal = true;
|
|
recursiveInitLocal = () {
|
|
print('Executing initializer');
|
|
if (doRecursiveInitLocal) {
|
|
doRecursiveInitLocal = false;
|
|
print('Trigger recursive initialization');
|
|
int val = local;
|
|
print('Final local has value $val');
|
|
print('Returning 4 from initializer');
|
|
return 4;
|
|
}
|
|
print('Returning 3 from initializer');
|
|
return 3;
|
|
};
|
|
|
|
throws(() {
|
|
int val = local;
|
|
print('Final local has value $val');
|
|
}, "Read local");
|
|
}
|
|
|
|
expect(expected, actual) {
|
|
if (expected != actual) throw 'Expected $expected, actual $actual';
|
|
}
|
|
|
|
throws(f(), String message) {
|
|
dynamic value;
|
|
try {
|
|
value = f();
|
|
} on Error catch (e) {
|
|
print(e);
|
|
return;
|
|
}
|
|
throw '$message: $value';
|
|
}
|