blob: 16c8e791c2285f23f3b162ff5c93f9624ec33060 [file] [log] [blame]
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 {
covariant-by-class 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}{core::bool} ?{self::A::T%} let final self::A::T? #t1 = this.{self::A::_#A#x}{self::A::T?} in #t1{self::A::T%} : throw new _in::LateError::fieldNI("x");
set x(covariant-by-class 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 {
covariant-by-class 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}{self::B::T?};
set y(covariant-by-class 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::==}{(core::Object) core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}
static method throws(() void f) dynamic {
try {
f(){() void};
}
on core::Object catch(final core::Object _) {
return;
}
throw "Expected exception";
}