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>
108 lines
6.4 KiB
Plaintext
108 lines
6.4 KiB
Plaintext
library /*isNonNullableByDefault*/;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
import "dart:_internal" as _in;
|
|
|
|
class Class extends core::Object {
|
|
static field core::int nonNullableStaticFieldReads = 0;
|
|
static field core::int? _#nonNullableStaticField = null;
|
|
static field core::bool _#nonNullableStaticField#isSet = false;
|
|
static field core::int nullableStaticFieldReads = 0;
|
|
static field core::int? _#nullableStaticField = null;
|
|
static field core::bool _#nullableStaticField#isSet = false;
|
|
field core::int nonNullableInstanceFieldReads = 0;
|
|
field core::int? _#Class#nonNullableInstanceField = null;
|
|
field core::bool _#Class#nonNullableInstanceField#isSet = false;
|
|
field core::int nullableInstanceFieldReads = 0;
|
|
field core::int? _#Class#nullableInstanceField = null;
|
|
field core::bool _#Class#nullableInstanceField#isSet = false;
|
|
synthetic constructor •() → self::Class
|
|
: super core::Object::•()
|
|
;
|
|
static get nonNullableStaticField() → core::int {
|
|
if(!self::Class::_#nonNullableStaticField#isSet) {
|
|
final core::int #t1 = (let final core::int #t2 = self::Class::nonNullableStaticFieldReads in let final core::int #t3 = self::Class::nonNullableStaticFieldReads = #t2.{core::num::+}(1) in #t2).{core::num::==}(0) ?{core::int} self::Class::nonNullableStaticField.{core::num::+}(1) : 0;
|
|
if(self::Class::_#nonNullableStaticField#isSet)
|
|
throw new _in::LateError::fieldADI("nonNullableStaticField");
|
|
self::Class::_#nonNullableStaticField = #t1;
|
|
self::Class::_#nonNullableStaticField#isSet = true;
|
|
}
|
|
return let final core::int? #t4 = self::Class::_#nonNullableStaticField in #t4{core::int};
|
|
}
|
|
static get nullableStaticField() → core::int? {
|
|
if(!self::Class::_#nullableStaticField#isSet) {
|
|
final core::int? #t5 = (let final core::int #t6 = self::Class::nullableStaticFieldReads in let final core::int #t7 = self::Class::nullableStaticFieldReads = #t6.{core::num::+}(1) in #t6).{core::num::==}(0) ?{core::int} self::Class::nullableStaticField.{core::Object::hashCode} : 0;
|
|
if(self::Class::_#nullableStaticField#isSet)
|
|
throw new _in::LateError::fieldADI("nullableStaticField");
|
|
self::Class::_#nullableStaticField = #t5;
|
|
self::Class::_#nullableStaticField#isSet = true;
|
|
}
|
|
return self::Class::_#nullableStaticField;
|
|
}
|
|
get nonNullableInstanceField() → core::int {
|
|
if(!this.{self::Class::_#Class#nonNullableInstanceField#isSet}) {
|
|
final core::int #t8 = (let final core::int #t9 = this.{self::Class::nonNullableInstanceFieldReads} in let final core::int #t10 = this.{self::Class::nonNullableInstanceFieldReads} = #t9.{core::num::+}(1) in #t9).{core::num::==}(0) ?{core::int} this.{self::Class::nonNullableInstanceField}.{core::num::+}(1) : 0;
|
|
if(this.{self::Class::_#Class#nonNullableInstanceField#isSet})
|
|
throw new _in::LateError::fieldADI("nonNullableInstanceField");
|
|
this.{self::Class::_#Class#nonNullableInstanceField} = #t8;
|
|
this.{self::Class::_#Class#nonNullableInstanceField#isSet} = true;
|
|
}
|
|
return let final core::int? #t11 = this.{self::Class::_#Class#nonNullableInstanceField} in #t11{core::int};
|
|
}
|
|
get nullableInstanceField() → core::int? {
|
|
if(!this.{self::Class::_#Class#nullableInstanceField#isSet}) {
|
|
final core::int? #t12 = (let final core::int #t13 = this.{self::Class::nullableInstanceFieldReads} in let final core::int #t14 = this.{self::Class::nullableInstanceFieldReads} = #t13.{core::num::+}(1) in #t13).{core::num::==}(0) ?{core::int} this.{self::Class::nullableInstanceField}.{core::Object::hashCode} : 0;
|
|
if(this.{self::Class::_#Class#nullableInstanceField#isSet})
|
|
throw new _in::LateError::fieldADI("nullableInstanceField");
|
|
this.{self::Class::_#Class#nullableInstanceField} = #t12;
|
|
this.{self::Class::_#Class#nullableInstanceField#isSet} = true;
|
|
}
|
|
return this.{self::Class::_#Class#nullableInstanceField};
|
|
}
|
|
}
|
|
static field core::int nonNullableTopLevelFieldReads = 0;
|
|
static field core::int? _#nonNullableTopLevelField = null;
|
|
static field core::bool _#nonNullableTopLevelField#isSet = false;
|
|
static field core::int nullableTopLevelFieldReads = 0;
|
|
static field core::int? _#nullableTopLevelField = null;
|
|
static field core::bool _#nullableTopLevelField#isSet = false;
|
|
static get nonNullableTopLevelField() → core::int {
|
|
if(!self::_#nonNullableTopLevelField#isSet) {
|
|
final core::int #t15 = (let final core::int #t16 = self::nonNullableTopLevelFieldReads in let final core::int #t17 = self::nonNullableTopLevelFieldReads = #t16.{core::num::+}(1) in #t16).{core::num::==}(0) ?{core::int} self::nonNullableTopLevelField.{core::num::+}(1) : 0;
|
|
if(self::_#nonNullableTopLevelField#isSet)
|
|
throw new _in::LateError::fieldADI("nonNullableTopLevelField");
|
|
self::_#nonNullableTopLevelField = #t15;
|
|
self::_#nonNullableTopLevelField#isSet = true;
|
|
}
|
|
return let final core::int? #t18 = self::_#nonNullableTopLevelField in #t18{core::int};
|
|
}
|
|
static get nullableTopLevelField() → core::int? {
|
|
if(!self::_#nullableTopLevelField#isSet) {
|
|
final core::int? #t19 = (let final core::int #t20 = self::nullableTopLevelFieldReads in let final core::int #t21 = self::nullableTopLevelFieldReads = #t20.{core::num::+}(1) in #t20).{core::num::==}(0) ?{core::int} self::nullableTopLevelField.{core::Object::hashCode} : 0;
|
|
if(self::_#nullableTopLevelField#isSet)
|
|
throw new _in::LateError::fieldADI("nullableTopLevelField");
|
|
self::_#nullableTopLevelField = #t19;
|
|
self::_#nullableTopLevelField#isSet = true;
|
|
}
|
|
return self::_#nullableTopLevelField;
|
|
}
|
|
static method main() → void {
|
|
self::throws(() → core::int => self::nonNullableTopLevelField, "Read nonNullableTopLevelField");
|
|
self::throws(() → core::int? => self::nullableTopLevelField, "Read nullableTopLevelField");
|
|
self::throws(() → core::int => self::Class::nonNullableStaticField, "Read nonNullableStaticField");
|
|
self::throws(() → core::int? => self::Class::nullableStaticField, "Read nullableStaticField");
|
|
self::throws(() → core::int => new self::Class::•().{self::Class::nonNullableInstanceField}, "Read nonNullableInstanceField");
|
|
self::throws(() → core::int? => new self::Class::•().{self::Class::nullableInstanceField}, "Read nullableInstanceField");
|
|
}
|
|
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}";
|
|
}
|