| library /*isNonNullableByDefault*/; |
| import self as self; |
| import "dart:core" as core; |
| import "dart:collection" as col; |
| |
| static method foldInitialElements() → void { |
| dynamic element0 = 0; |
| core::int? element1 = 1; |
| core::int element2 = 2; |
| core::List<core::int?> list = block { |
| final core::List<core::int?> #t1 = <core::int?>[element0 as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?, element1{core::int}, element2]; |
| if(true) |
| #t1.{core::List::add}{Invariant}(3){(core::int?) → void}; |
| #t1.{core::List::add}{Invariant}(4){(core::int?) → void}; |
| #t1.{core::List::add}{Invariant}(5){(core::int?) → void}; |
| #t1.{core::List::add}{Invariant}(6){(core::int?) → void}; |
| } =>#t1; |
| self::expect(core::List::generate<core::int?>(7, (core::int? i) → core::int? => i), list); |
| core::Set<core::int?> set = block { |
| final core::Set<core::int?> #t2 = col::LinkedHashSet::•<core::int?>(); |
| #t2.{core::Set::add}{Invariant}(element0 as{TypeError,ForDynamic,ForNonNullableByDefault} core::int?){(core::int?) → core::bool}; |
| #t2.{core::Set::add}{Invariant}(element1{core::int}){(core::int?) → core::bool}; |
| #t2.{core::Set::add}{Invariant}(element2){(core::int?) → core::bool}; |
| if(true) |
| #t2.{core::Set::add}{Invariant}(3){(core::int?) → core::bool}; |
| #t2.{core::Set::add}{Invariant}(4){(core::int?) → core::bool}; |
| #t2.{core::Set::add}{Invariant}(5){(core::int?) → core::bool}; |
| #t2.{core::Set::add}{Invariant}(6){(core::int?) → core::bool}; |
| } =>#t2; |
| self::expect(core::List::generate<core::int?>(7, (core::int? i) → core::int? => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int?>}); |
| } |
| static method foldInitialSpread1() → void { |
| dynamic initial = <core::int>[0, 1, 2]; |
| core::List<core::int> list = block { |
| final core::List<core::int> #t3 = <core::int>[]; |
| for (final has-declared-initializer dynamic #t4 in initial as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::int #t5 = #t4 as{TypeError,ForNonNullableByDefault} core::int; |
| #t3.{core::List::add}{Invariant}(#t5){(core::int) → void}; |
| } |
| if(true) |
| #t3.{core::List::add}{Invariant}(3){(core::int) → void}; |
| #t3.{core::List::add}{Invariant}(4){(core::int) → void}; |
| #t3.{core::List::add}{Invariant}(5){(core::int) → void}; |
| #t3.{core::List::add}{Invariant}(6){(core::int) → void}; |
| } =>#t3; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), list); |
| core::Set<core::int> set = block { |
| final core::Set<core::int> #t6 = col::LinkedHashSet::•<core::int>(); |
| for (final has-declared-initializer dynamic #t7 in initial as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::int #t8 = #t7 as{TypeError,ForNonNullableByDefault} core::int; |
| #t6.{core::Set::add}{Invariant}(#t8){(core::int) → core::bool}; |
| } |
| if(true) |
| #t6.{core::Set::add}{Invariant}(3){(core::int) → core::bool}; |
| #t6.{core::Set::add}{Invariant}(4){(core::int) → core::bool}; |
| #t6.{core::Set::add}{Invariant}(5){(core::int) → core::bool}; |
| #t6.{core::Set::add}{Invariant}(6){(core::int) → core::bool}; |
| } =>#t6; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int>}); |
| } |
| static method foldInitialSpread2([core::bool c = #C1]) → void { |
| core::Iterable<core::int?> initial = <core::int?>[0, 1, 2]; |
| if(c) { |
| initial = <core::int?>[null]; |
| } |
| core::List<core::int?> list = block { |
| final core::List<core::int?> #t9 = core::List::of<core::int?>(initial); |
| if(true) |
| #t9.{core::List::add}{Invariant}(3){(core::int?) → void}; |
| #t9.{core::List::add}{Invariant}(4){(core::int?) → void}; |
| #t9.{core::List::add}{Invariant}(5){(core::int?) → void}; |
| #t9.{core::List::add}{Invariant}(6){(core::int?) → void}; |
| } =>#t9; |
| self::expect(core::List::generate<core::int?>(7, (core::int? i) → core::int? => i), list); |
| core::Set<core::int?> set = block { |
| final core::Set<core::int?> #t10 = col::LinkedHashSet::of<core::int?>(initial); |
| if(true) |
| #t10.{core::Set::add}{Invariant}(3){(core::int?) → core::bool}; |
| #t10.{core::Set::add}{Invariant}(4){(core::int?) → core::bool}; |
| #t10.{core::Set::add}{Invariant}(5){(core::int?) → core::bool}; |
| #t10.{core::Set::add}{Invariant}(6){(core::int?) → core::bool}; |
| } =>#t10; |
| self::expect(core::List::generate<core::int?>(7, (core::int? i) → core::int? => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int?>}); |
| } |
| static method foldInitialSpread3([core::bool c = #C1]) → void { |
| core::List<core::int?> initial = <core::int?>[0, 1, 2]; |
| if(c) { |
| initial = <core::int?>[null]; |
| } |
| core::List<core::int?> list = block { |
| final core::List<core::int?> #t11 = core::List::of<core::int?>(initial); |
| if(true) |
| #t11.{core::List::add}{Invariant}(3){(core::int?) → void}; |
| #t11.{core::List::add}{Invariant}(4){(core::int?) → void}; |
| #t11.{core::List::add}{Invariant}(5){(core::int?) → void}; |
| #t11.{core::List::add}{Invariant}(6){(core::int?) → void}; |
| } =>#t11; |
| self::expect(core::List::generate<core::int?>(7, (core::int? i) → core::int? => i), list); |
| core::Set<core::int?> set = block { |
| final core::Set<core::int?> #t12 = col::LinkedHashSet::of<core::int?>(initial); |
| if(true) |
| #t12.{core::Set::add}{Invariant}(3){(core::int?) → core::bool}; |
| #t12.{core::Set::add}{Invariant}(4){(core::int?) → core::bool}; |
| #t12.{core::Set::add}{Invariant}(5){(core::int?) → core::bool}; |
| #t12.{core::Set::add}{Invariant}(6){(core::int?) → core::bool}; |
| } =>#t12; |
| self::expect(core::List::generate<core::int?>(7, (core::int? i) → core::int? => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int?>}); |
| } |
| static method foldInitialSpread4([core::bool c = #C1]) → void { |
| core::Iterable<core::int> initial = <core::int>[0, 1, 2]; |
| core::List<core::int> list = block { |
| final core::List<core::int> #t13 = core::List::of<core::int>(initial); |
| if(true) |
| #t13.{core::List::add}{Invariant}(3){(core::int) → void}; |
| #t13.{core::List::add}{Invariant}(4){(core::int) → void}; |
| #t13.{core::List::add}{Invariant}(5){(core::int) → void}; |
| #t13.{core::List::add}{Invariant}(6){(core::int) → void}; |
| } =>#t13; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), list); |
| core::Set<core::int> set = block { |
| final core::Set<core::int> #t14 = col::LinkedHashSet::of<core::int>(initial); |
| if(true) |
| #t14.{core::Set::add}{Invariant}(3){(core::int) → core::bool}; |
| #t14.{core::Set::add}{Invariant}(4){(core::int) → core::bool}; |
| #t14.{core::Set::add}{Invariant}(5){(core::int) → core::bool}; |
| #t14.{core::Set::add}{Invariant}(6){(core::int) → core::bool}; |
| } =>#t14; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int>}); |
| } |
| static method foldInitialSpread5([core::bool c = #C1]) → void { |
| core::List<core::int> initial = <core::int>[0, 1, 2]; |
| core::List<core::int> list = block { |
| final core::List<core::int> #t15 = core::List::of<core::int>(initial); |
| if(true) |
| #t15.{core::List::add}{Invariant}(3){(core::int) → void}; |
| #t15.{core::List::add}{Invariant}(4){(core::int) → void}; |
| #t15.{core::List::add}{Invariant}(5){(core::int) → void}; |
| #t15.{core::List::add}{Invariant}(6){(core::int) → void}; |
| } =>#t15; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), list); |
| core::Set<core::int> set = block { |
| final core::Set<core::int> #t16 = col::LinkedHashSet::of<core::int>(initial); |
| if(true) |
| #t16.{core::Set::add}{Invariant}(3){(core::int) → core::bool}; |
| #t16.{core::Set::add}{Invariant}(4){(core::int) → core::bool}; |
| #t16.{core::Set::add}{Invariant}(5){(core::int) → core::bool}; |
| #t16.{core::Set::add}{Invariant}(6){(core::int) → core::bool}; |
| } =>#t16; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int>}); |
| } |
| static method foldInitialSpread6([core::bool c = #C1]) → void { |
| core::List<core::int>? initial = <core::int>[0, 1, 2]; |
| if(c) { |
| initial = null; |
| } |
| core::List<core::int> list = block { |
| final core::List<core::int> #t17 = <core::int>[]; |
| final core::Iterable<core::int>? #t18 = initial; |
| if(!(#t18 == null)) |
| #t17.{core::List::addAll}{Invariant}(#t18{core::Iterable<core::int>}){(core::Iterable<core::int>) → void}; |
| if(true) |
| #t17.{core::List::add}{Invariant}(3){(core::int) → void}; |
| #t17.{core::List::add}{Invariant}(4){(core::int) → void}; |
| #t17.{core::List::add}{Invariant}(5){(core::int) → void}; |
| #t17.{core::List::add}{Invariant}(6){(core::int) → void}; |
| } =>#t17; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), list); |
| core::Set<core::int> set = block { |
| final core::Set<core::int> #t19 = col::LinkedHashSet::•<core::int>(); |
| final core::Iterable<core::int>? #t20 = initial; |
| if(!(#t20 == null)) |
| #t19.{core::Set::addAll}{Invariant}(#t20{core::Iterable<core::int>}){(core::Iterable<core::int>) → void}; |
| if(true) |
| #t19.{core::Set::add}{Invariant}(3){(core::int) → core::bool}; |
| #t19.{core::Set::add}{Invariant}(4){(core::int) → core::bool}; |
| #t19.{core::Set::add}{Invariant}(5){(core::int) → core::bool}; |
| #t19.{core::Set::add}{Invariant}(6){(core::int) → core::bool}; |
| } =>#t19; |
| self::expect(core::List::generate<core::int>(7, (core::int i) → core::int => i), set.{core::Iterable::toList}(){({growable: core::bool}) → core::List<core::int>}); |
| } |
| static method main() → dynamic { |
| self::foldInitialElements(); |
| self::foldInitialSpread1(); |
| self::foldInitialSpread2(); |
| self::foldInitialSpread3(); |
| self::foldInitialSpread4(); |
| self::foldInitialSpread5(); |
| self::foldInitialSpread6(); |
| } |
| static method expect(core::List<dynamic> list1, core::List<dynamic> list2) → void { |
| if(!(list1.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} list2.{core::List::length}{core::int})) { |
| throw "Unexpected length. Expected ${list1.{core::List::length}{core::int}}, actual ${list2.{core::List::length}{core::int}}."; |
| } |
| for (core::int i = 0; i.{core::num::<}(list1.{core::List::length}{core::int}){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) { |
| if(!(list1.{core::List::[]}(i){(core::int) → dynamic} =={core::Object::==}{(core::Object) → core::bool} list2.{core::List::[]}(i){(core::int) → dynamic})) { |
| throw "Unexpected element at index ${i}. Expected ${list1.{core::List::[]}(i){(core::int) → dynamic}}, actual ${list2.{core::List::[]}(i){(core::int) → dynamic}}."; |
| } |
| } |
| } |
| |
| constants { |
| #C1 = false |
| } |