| library /*isNonNullableByDefault*/; |
| import self as self; |
| import "dart:core" as core; |
| import "dart:_internal" as _in; |
| |
| static method test1(dynamic x) → dynamic { |
| core::int a; |
| block { |
| final dynamic #0#0 = x; |
| 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 && (let final dynamic #t1 = a = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} as{ForNonNullableByDefault} core::int in true))) |
| throw new _in::ReachabilityError::•(); |
| } =>#0#0; |
| return a; |
| } |
| static method test2(dynamic x) → dynamic { |
| core::int a; |
| core::int b; |
| core::int c; |
| block { |
| final dynamic #1#0 = block { |
| 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::>=}(#C1){(core::num) → core::bool} && ((let final dynamic #t2 = a = #0#6{core::int} in true) && (let final dynamic #t3 = b = #0#6{core::int} in true)))) |
| throw new _in::ReachabilityError::•(); |
| } =>#0#0; |
| if(!(#1#0 is{ForNonNullableByDefault} core::List<dynamic> && #1#0{core::List<dynamic>}.{core::List::length}{core::int}.{core::num::>=}(#C1){(core::num) → core::bool} && (let final dynamic #t4 = c = #1#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} as{ForNonNullableByDefault} core::int in true))) |
| throw new _in::ReachabilityError::•(); |
| } =>#1#0; |
| return a.{core::num::+}(b){(core::num) → core::int}.{core::num::+}(c){(core::num) → core::int}; |
| } |
| static method main() → dynamic { |
| self::expectEquals(self::test1(<core::int>[1]), 1); |
| self::expectThrows(() → void => self::test1(<dynamic>[])); |
| self::expectThrows(() → void => self::test1(<core::int>[1, 2, 3])); |
| self::expectThrows(() → void => self::test1("foo")); |
| self::expectThrows(() → void => self::test1(null)); |
| self::expectEquals(self::test2(<core::int>[1]), 3); |
| self::expectThrows(() → void => self::test2(1)); |
| } |
| 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 the function to throw."; |
| } |
| } |
| |
| constants { |
| #C1 = 1 |
| } |