Files
sdk/pkg/front_end/testcases/late_lowering/issue42407.dart.weak.expect
T
Johnni Winther 0609c6dacc [cfe] Add predefined constructors for late error messages
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>
2020-11-03 12:47:06 +00:00

51 lines
1.7 KiB
Plaintext

library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class A<T extends core::Object? = dynamic> extends core::Object {
generic-covariant-impl field self::A::T? _#A#x = null;
field core::bool _#A#x#isSet = false;
synthetic constructor •() → self::A<self::A::T%>
: super core::Object::•()
;
get x() → self::A::T%
return this.{self::A::_#A#x#isSet} ?{self::A::T%} let final self::A::T? #t1 = this.{self::A::_#A#x} in #t1{self::A::T%} : throw new _in::LateError::fieldNI("x");
set x(generic-covariant-impl self::A::T% #t2) → void {
this.{self::A::_#A#x#isSet} = true;
this.{self::A::_#A#x} = #t2;
}
}
class B<T extends core::Object? = dynamic> extends core::Object {
generic-covariant-impl field self::B::T? _y = null;
synthetic constructor •() → self::B<self::B::T%>
: super core::Object::•()
;
get y() → self::B::T?
return this.{self::B::_y};
set y(generic-covariant-impl self::B::T? val) → void {
this.{self::B::_y} = val;
}
}
static method main() → dynamic {
self::A<core::num> a = new self::A::•<core::int>();
self::expect(42, a.{self::A::x} = 42);
self::throws(() → void => a.{self::A::x} = 0.5);
self::B<core::num> b = new self::B::•<core::int>();
self::expect(42, b.{self::B::y} = 42);
self::throws(() → void => b.{self::B::y} = 0.5);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!expected.{core::Object::==}(actual))
throw "Expected ${expected}, actual ${actual}";
}
static method throws(() → void f) → dynamic {
try {
f.call();
}
on core::Object catch(final core::Object _) {
return;
}
throw "Expected exception";
}