blob: 481015774692cb3d840a551db91139d64f1b3e5c [file] [log] [blame]
library;
import self as self;
import "dart:core" as core;
typedef B = self::A;
typedef D<X extends core::Object? = dynamic> = self::C<X%, X%>;
class A extends core::Object {
field core::int foo;
constructor •(core::int foo) self::A
: self::A::foo = foo, super core::Object::•()
;
}
class C<X extends core::Object? = dynamic, Y extends core::Object? = dynamic> extends core::Object {
covariant-by-class field self::C::X% x;
covariant-by-class field self::C::Y% y;
constructor •(self::C::X% x, self::C::Y% y) self::C<self::C::X%, self::C::Y%>
: self::C::x = x, self::C::y = y, super core::Object::•()
;
}
static method test1(dynamic x) dynamic {
{
final synthesized dynamic #0#0 = x;
{
hoisted core::int foo;
if(#0#0 is self::A) {
foo = #0#0{self::A}.{self::A::foo}{core::int};
{
return foo;
}
}
else {
return null;
}
}
}
}
static method test2(dynamic x) dynamic {
{
final synthesized dynamic #0#0 = x;
{
hoisted core::String x;
if(#0#0 is self::C<core::String, core::String>) {
x = #0#0{self::C<core::String, core::String>}.{self::C::x}{core::String};
{
return x;
}
}
else {
return null;
}
}
}
}
static method main() dynamic {
self::expectEquals(0, self::test1(new self::A::•(0)));
self::expectEquals(1, self::test1(new self::A::•(1)));
self::expectEquals(null, self::test1(null));
self::expectEquals("one", self::test2(new self::C::•<core::String, core::String>("one", "two")));
self::expectEquals("one", self::test2(new self::C::•<core::String, core::String>("one", "two")));
self::expectEquals(null, self::test2(null));
}
static method expectEquals(dynamic x, dynamic y) dynamic {
if(!(x =={core::Object::==}{(core::Object) core::bool} y)) {
throw "Expected ${x} to be equal to ${y}.";
}
}
static method _#D#new#tearOff<X extends core::Object? = dynamic>(self::_#D#new#tearOff::X% x, self::_#D#new#tearOff::X% y) → self::C<self::_#D#new#tearOff::X%, self::_#D#new#tearOff::X%>
return new self::C::•<self::_#D#new#tearOff::X%, self::_#D#new#tearOff::X%>(x, y);