4bf22f41f3
Change-Id: Ideee9917b2e5b819672c7e441d051f9bc57c86c6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366342 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
87 lines
3.9 KiB
Plaintext
87 lines
3.9 KiB
Plaintext
library;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
static method test1(dynamic x) → dynamic {
|
|
{
|
|
final synthesized dynamic #0#0 = x;
|
|
synthesized dynamic #0#6;
|
|
synthesized core::bool #0#6#isSet = false;
|
|
{
|
|
hoisted core::int y;
|
|
if(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t1 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int) {
|
|
y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t2 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int;
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
static method test2(dynamic x) → dynamic {
|
|
{
|
|
final synthesized dynamic #0#0 = x;
|
|
synthesized dynamic #0#6;
|
|
synthesized core::bool #0#6#isSet = false;
|
|
{
|
|
hoisted core::int y;
|
|
if(#0#0 is core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int}.{core::num::>=}(#C1){(core::num) → core::bool} && (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t3 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) is core::int) {
|
|
y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t4 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}) as{Unchecked} core::int;
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
static method test3(dynamic x) → dynamic {
|
|
{
|
|
final synthesized dynamic #0#0 = x;
|
|
synthesized core::int #0#2;
|
|
synthesized core::bool #0#2#isSet = false;
|
|
synthesized dynamic #0#6;
|
|
synthesized core::bool #0#6#isSet = false;
|
|
{
|
|
hoisted core::int y;
|
|
if(#0#0 is core::List<dynamic> && (#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t5 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}).{core::num::>=}(#C1){(core::num) → core::bool} && (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t6 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}((#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t7 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}).{core::num::-}(1){(core::num) → core::int}){(core::int) → dynamic}) is core::int) {
|
|
y = (#0#6#isSet ?{dynamic} #0#6{dynamic} : let final dynamic #t8 = #0#6#isSet = true in #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}((#0#2#isSet ?{core::int} #0#2{core::int} : let final dynamic #t9 = #0#2#isSet = true in #0#2 = #0#0{core::List<dynamic>}.{core::List::length}{core::int}).{core::num::-}(1){(core::num) → core::int}){(core::int) → dynamic}) as{Unchecked} core::int;
|
|
{
|
|
return y;
|
|
}
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
static method main() → dynamic {
|
|
self::expectEquals(self::test1(<core::int>[1]), 1);
|
|
self::expectEquals(self::test1(<core::int>[1, 2, 3]), null);
|
|
self::expectEquals(self::test1(<dynamic>[]), null);
|
|
self::expectEquals(self::test1("foo"), null);
|
|
self::expectEquals(self::test2(<core::int>[1]), 1);
|
|
self::expectEquals(self::test2(<core::int>[1, 2, 3]), 1);
|
|
self::expectEquals(self::test2(<dynamic>[]), null);
|
|
self::expectEquals(self::test2("foo"), null);
|
|
self::expectEquals(self::test3(<core::int>[1]), 1);
|
|
self::expectEquals(self::test3(<core::int>[1, 2, 3]), 3);
|
|
self::expectEquals(self::test3(<dynamic>[]), null);
|
|
self::expectEquals(self::test3("foo"), 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}.";
|
|
}
|
|
}
|
|
|
|
constants {
|
|
#C1 = 1
|
|
}
|