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>
57 lines
1.8 KiB
Dart
57 lines
1.8 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.
|
|
|
|
int nonNullableTopLevelFieldReads = 0;
|
|
|
|
late final int nonNullableTopLevelField =
|
|
nonNullableTopLevelFieldReads++ == 0 ? nonNullableTopLevelField + 1 : 0;
|
|
|
|
int nullableTopLevelFieldReads = 0;
|
|
|
|
late final int? nullableTopLevelField =
|
|
nullableTopLevelFieldReads++ == 0 ? nullableTopLevelField.hashCode : 0;
|
|
|
|
class Class {
|
|
static int nonNullableStaticFieldReads = 0;
|
|
|
|
static late final int nonNullableStaticField =
|
|
nonNullableStaticFieldReads++ == 0 ? nonNullableStaticField + 1 : 0;
|
|
|
|
static int nullableStaticFieldReads = 0;
|
|
|
|
static late final int? nullableStaticField =
|
|
nullableStaticFieldReads++ == 0 ? nullableStaticField.hashCode : 0;
|
|
|
|
int nonNullableInstanceFieldReads = 0;
|
|
|
|
late final int nonNullableInstanceField =
|
|
nonNullableInstanceFieldReads++ == 0 ? nonNullableInstanceField + 1 : 0;
|
|
|
|
int nullableInstanceFieldReads = 0;
|
|
|
|
late final int? nullableInstanceField =
|
|
nullableInstanceFieldReads++ == 0 ? nullableInstanceField.hashCode : 0;
|
|
}
|
|
|
|
void main() {
|
|
throws(() => nonNullableTopLevelField, "Read nonNullableTopLevelField");
|
|
throws(() => nullableTopLevelField, "Read nullableTopLevelField");
|
|
throws(() => Class.nonNullableStaticField, "Read nonNullableStaticField");
|
|
throws(() => Class.nullableStaticField, "Read nullableStaticField");
|
|
throws(() => new Class().nonNullableInstanceField,
|
|
"Read nonNullableInstanceField");
|
|
throws(() => new Class().nullableInstanceField, "Read nullableInstanceField");
|
|
}
|
|
|
|
throws(f(), String message) {
|
|
dynamic value;
|
|
try {
|
|
value = f();
|
|
} on Error catch (e) {
|
|
print(e);
|
|
return;
|
|
}
|
|
throw '$message: $value';
|
|
}
|