blob: b2aae10d1f1ff4a8a4dde3f8efc64a987512109d [file] [log] [blame]
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
static method test1(dynamic x) dynamic {
{
core::int i;
{
final dynamic #0#0 = x;
late final dynamic #0#6 = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic};
if(!(#0#0 is{ForNonNullableByDefault} core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C1 && (#0#6 is{ForNonNullableByDefault} core::int && (let final dynamic #t1 = i = #0#6{core::int} in true))))
throw new _in::ReachabilityError::•();
}
final core::int #t2 = i;
for (core::int i = #t2; true; ) {
return i;
}
}
}
static method test2(core::List<core::int> x) dynamic {
core::List<core::int> result = <core::int>[];
{
core::int c;
core::int n;
{
final dynamic #0#0 = x;
if(!(#0#0{core::List<core::int>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C2 && (let final dynamic #t3 = c = #0#0{core::List<core::int>}.{core::List::[]}(0){(core::int) → core::int} in true) && (let final dynamic #t4 = n = #0#0{core::List<core::int>}.{core::List::[]}(1){(core::int) → core::int} in true)))
throw new _in::ReachabilityError::•();
}
final core::int #t5 = c;
final core::int #t6 = n;
for (core::int c = #t5, core::int n = #t6; c.{core::num::<}(n){(core::num) → core::bool}; result.{core::List::add}(c){(core::int) → void}) {
result.{core::List::add}(c){(core::int) void};
c = c.{core::num::+}(1){(core::num) core::int};
}
}
return result;
}
static method main() dynamic {
self::expectEquals(self::test1(<core::int>[0]), 0);
self::expectThrows(() void => self::test1(<dynamic>[]));
self::expectEquals(self::listToString(self::test2(<core::int>[1, 2]) as{TypeError,ForDynamic,ForNonNullableByDefault} core::List<dynamic>), self::listToString(<dynamic>[1, 2]));
}
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 expectThrows(() void f) dynamic {
core::bool hasThrown = true;
try {
f(){() void};
hasThrown = false;
}
on core::Object catch(final core::Object e) {
}
if(!hasThrown) {
throw "Expected function to throw.";
}
}
static method listToString(core::List<dynamic> list) dynamic
return "[${list.{core::Iterable::map}<core::String>((dynamic e) → core::String => "${e}"){((dynamic) → core::String) → core::Iterable<core::String>}.{core::Iterable::join}(","){([core::String]) → core::String}}]";
constants {
#C1 = 1
#C2 = 2
}