blob: efee1681b8fcf80fca7735a85cc79f147d8e827c [file] [log] [blame]
library;
import self as self;
import "dart:core" as core;
static method test1(dynamic x) dynamic {
#L1:
{
final synthesized dynamic #0#0 = x;
{
hoisted core::int x;
if(#0#0 is core::int && (let final dynamic #t1 = x = #0#0{core::int} in true)) {
{
{
core::String x = "foo";
return x;
}
}
}
}
{
{
{
return "bar";
}
}
}
}
}
static method test2(dynamic x) dynamic {
#L2:
{
final synthesized dynamic #0#0 = x;
late final synthesized core::bool #0#4 = #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1;
late final synthesized dynamic #0#6 = (#0#0 as{Unchecked} core::List<dynamic>).{core::List::[]}(0){(core::int) → dynamic};
late final synthesized dynamic #0#7 = (#0#0 as{Unchecked} core::List<dynamic>).{core::List::[]}(1){(core::int) → dynamic};
{
lowered hoisted core::int x#case#0;
lowered hoisted core::int x#case#1;
if(#0#0 is core::List<dynamic> && #0#4 && (#0#6 is core::int && (let final dynamic #t2 = x#case#0 = #0#6{core::int} in true)) || #0#0 is core::List<dynamic> && #0#4 && (#0#7 is core::int && (let final dynamic #t3 = x#case#1 = #0#7{core::int} in true))) {
{
core::String x = "foo";
return x;
}
}
}
{
{
{
return "bar";
}
}
}
}
}
static method test3(dynamic x) dynamic {
{
hoisted core::int x;
final synthesized dynamic #0#0 = x;
if(#0#0 is core::int && (let final dynamic #t4 = x = #0#0{core::int} in true)) {
core::String x = "foo";
return x;
}
else {
return "bar";
}
}
}
static method test4(dynamic x) dynamic {
core::Function f = () core::int => 0;
{
hoisted core::int x;
final synthesized dynamic #0#0 = x;
if(#0#0 is core::int && (let final dynamic #t5 = x = #0#0{core::int} in true)) {
core::String x = (() core::String {
f = () core::int => 1;
return "foo";
})(){() core::String};
}
}
return f();
}
static method main() dynamic {
self::expectEquals(self::test1(0), "foo");
self::expectEquals(self::test1("foo"), "bar");
self::expectEquals(self::test2(<core::Object>[0, false]), "foo");
self::expectEquals(self::test2(<core::Object>[false, 0]), "foo");
self::expectEquals(self::test2("foo"), "bar");
self::expectEquals(self::test3(0), "foo");
self::expectEquals(self::test3("foo"), "bar");
self::expectEquals(self::test4(0), 1);
self::expectEquals(self::test4("foo"), 0);
}
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}'.";
}
}
constants {
#C1 = 2
}