Files
sdk/pkg/front_end/testcases/late_lowering/issue44372.dart.weak.expect
T
Lasse R.H. Nielsen ef8cc2c1cf Remove LateInitializationError.
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>
2021-01-12 20:21:33 +00:00

61 lines
2.0 KiB
Plaintext

library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
static method main(core::List<core::String> args) → dynamic {
lowered () →? core::int #recursiveInitLocal;
lowered core::bool #recursiveInitLocal#isSet = false;
function #recursiveInitLocal#get() → () → core::int
return #recursiveInitLocal#isSet ?{() → core::int} #recursiveInitLocal{() → core::int} : throw new _in::LateError::localNI("recursiveInitLocal");
function #recursiveInitLocal#set(() → core::int #t1) → dynamic {
#recursiveInitLocal#isSet = true;
return #recursiveInitLocal = #t1;
}
lowered final core::int? #local;
lowered core::bool #local#isSet = false;
function #local#get() → core::int {
if(!#local#isSet) {
final core::int #t2 = #recursiveInitLocal#get.call().call();
if(#local#isSet)
throw new _in::LateError::localADI("local");
#local = #t2;
#local#isSet = true;
}
return #local{core::int};
}
core::bool doRecursiveInitLocal = true;
#recursiveInitLocal#set.call(() → core::int {
core::print("Executing initializer");
if(doRecursiveInitLocal) {
doRecursiveInitLocal = false;
core::print("Trigger recursive initialization");
core::int val = #local#get.call();
core::print("Final local has value ${val}");
core::print("Returning 4 from initializer");
return 4;
}
core::print("Returning 3 from initializer");
return 3;
});
self::throws(() → Null {
core::int val = #local#get.call();
core::print("Final local has value ${val}");
}, "Read local");
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!expected.{core::Object::==}(actual))
throw "Expected ${expected}, actual ${actual}";
}
static method throws(() → dynamic f, core::String message) → dynamic {
dynamic value;
try {
value = f.call();
}
on core::Error catch(final core::Error e) {
core::print(e);
return;
}
throw "${message}: ${value}";
}