0609c6dacc
This CL adds predefined constructors to LateInitializationErrorImpl that only take the name of the late field/variable as argument. This can reduce the size of the generated code for ddc/dart2js size because the long message isn't repeated at all call sites. In response to #43995 Change-Id: Ie276dd1455feab1655da3a503856da425b20f04f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169883 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Stephen Adams <sra@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
library /*isNonNullableByDefault*/;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
import "dart:_internal" as _in;
|
|
|
|
class C extends core::Object {
|
|
field core::num pi = 3.14;
|
|
field core::num? _#C#p1 = null;
|
|
field core::bool _#C#p1#isSet = false;
|
|
field core::num? _#C#p2 = null;
|
|
field core::bool _#C#p2#isSet = false;
|
|
synthetic constructor •() → self::C
|
|
: super core::Object::•()
|
|
;
|
|
get p1() → core::num {
|
|
if(!this.{self::C::_#C#p1#isSet}) {
|
|
this.{self::C::_#C#p1} = this.{self::C::pi};
|
|
this.{self::C::_#C#p1#isSet} = true;
|
|
}
|
|
return let final core::num? #t1 = this.{self::C::_#C#p1} in #t1{core::num};
|
|
}
|
|
set p1(core::num #t2) → void {
|
|
this.{self::C::_#C#p1#isSet} = true;
|
|
this.{self::C::_#C#p1} = #t2;
|
|
}
|
|
get p2() → core::num {
|
|
if(!this.{self::C::_#C#p2#isSet}) {
|
|
final core::num #t3 = this.{self::C::pi};
|
|
if(this.{self::C::_#C#p2#isSet})
|
|
throw new _in::LateError::fieldADI("p2");
|
|
this.{self::C::_#C#p2} = #t3;
|
|
this.{self::C::_#C#p2#isSet} = true;
|
|
}
|
|
return let final core::num? #t4 = this.{self::C::_#C#p2} in #t4{core::num};
|
|
}
|
|
}
|
|
static method main() → dynamic {
|
|
self::expect(3.14, new self::C::•().{self::C::p1});
|
|
self::expect(3.14, new self::C::•().{self::C::p2});
|
|
}
|
|
static method expect(dynamic expected, dynamic actual) → dynamic {
|
|
if(!expected.{core::Object::==}(actual))
|
|
throw "Expected ${expected}, actual ${actual}";
|
|
}
|