| library /*isNonNullableByDefault*/; |
| import self as self; |
| import "dart:core" as core; |
| |
| static method useAddAll() → void { |
| dynamic dynamicList1 = <core::int>[0, 1, 2]; |
| dynamic dynamicList2 = <core::num>[3, 4, 5]; |
| dynamic dynamicList3 = <core::int?>[6, 7, 8]; |
| core::Iterable<core::int> iterableIntList = <core::int>[9, 10, 11]; |
| core::List<core::int> intList = <core::int>[12, 13, 14]; |
| core::List<core::int> list1 = block { |
| final core::List<core::int> #t1 = <core::int>[]; |
| for (final dynamic #t2 in dynamicList1 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::int #t3 = #t2 as{TypeError,ForNonNullableByDefault} core::int; |
| #t1.{core::List::add}{Invariant}(#t3); |
| } |
| for (final dynamic #t4 in dynamicList2 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::int #t5 = #t4 as{TypeError,ForNonNullableByDefault} core::int; |
| #t1.{core::List::add}{Invariant}(#t5); |
| } |
| for (final dynamic #t6 in dynamicList3 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::int #t7 = #t6 as{TypeError,ForNonNullableByDefault} core::int; |
| #t1.{core::List::add}{Invariant}(#t7); |
| } |
| #t1.{core::List::addAll}{Invariant}(iterableIntList); |
| #t1.{core::List::addAll}{Invariant}(intList); |
| } =>#t1; |
| self::expect(core::List::generate<core::int>(15, (core::int i) → core::int => i), list1); |
| core::List<core::num> list2 = block { |
| final core::List<core::num> #t8 = <core::num>[]; |
| for (final dynamic #t9 in dynamicList1 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::num #t10 = #t9 as{TypeError,ForNonNullableByDefault} core::num; |
| #t8.{core::List::add}{Invariant}(#t10); |
| } |
| for (final dynamic #t11 in dynamicList2 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::num #t12 = #t11 as{TypeError,ForNonNullableByDefault} core::num; |
| #t8.{core::List::add}{Invariant}(#t12); |
| } |
| for (final dynamic #t13 in dynamicList3 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>) { |
| final core::num #t14 = #t13 as{TypeError,ForNonNullableByDefault} core::num; |
| #t8.{core::List::add}{Invariant}(#t14); |
| } |
| #t8.{core::List::addAll}{Invariant}(iterableIntList); |
| #t8.{core::List::addAll}{Invariant}(intList); |
| } =>#t8; |
| self::expect(core::List::generate<core::num>(15, (core::int i) → core::int => i), list2); |
| } |
| static method useAddAllNullable() → void { |
| dynamic dynamicList1 = <core::int>[0, 1, 2]; |
| dynamic dynamicList2 = <core::num>[3, 4, 5]; |
| dynamic dynamicList3 = <core::int?>[6, 7, 8]; |
| core::Iterable<core::int>? iterableIntList = true ?{core::List<core::int>?} <core::int>[9, 10, 11] : null; |
| core::List<core::int>? intList = true ?{core::List<core::int>?} <core::int>[12, 13, 14] : null; |
| core::List<core::int> list1 = block { |
| final core::List<core::int> #t15 = <core::int>[]; |
| final core::Iterable<dynamic>? #t16 = dynamicList1 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>?; |
| if(!#t16.{core::Object::==}(null)) |
| for (final dynamic #t17 in #t16{core::Iterable<dynamic>}) { |
| final core::int #t18 = #t17 as{TypeError,ForNonNullableByDefault} core::int; |
| #t15.{core::List::add}{Invariant}(#t18); |
| } |
| final core::Iterable<dynamic>? #t19 = dynamicList2 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>?; |
| if(!#t19.{core::Object::==}(null)) |
| for (final dynamic #t20 in #t19{core::Iterable<dynamic>}) { |
| final core::int #t21 = #t20 as{TypeError,ForNonNullableByDefault} core::int; |
| #t15.{core::List::add}{Invariant}(#t21); |
| } |
| final core::Iterable<dynamic>? #t22 = dynamicList3 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>?; |
| if(!#t22.{core::Object::==}(null)) |
| for (final dynamic #t23 in #t22{core::Iterable<dynamic>}) { |
| final core::int #t24 = #t23 as{TypeError,ForNonNullableByDefault} core::int; |
| #t15.{core::List::add}{Invariant}(#t24); |
| } |
| final core::Iterable<core::int>? #t25 = iterableIntList; |
| if(!#t25.{core::Object::==}(null)) |
| #t15.{core::List::addAll}{Invariant}(#t25{core::Iterable<core::int>}); |
| final core::Iterable<core::int>? #t26 = intList; |
| if(!#t26.{core::Object::==}(null)) |
| #t15.{core::List::addAll}{Invariant}(#t26{core::Iterable<core::int>}); |
| } =>#t15; |
| self::expect(core::List::generate<core::int>(15, (core::int i) → core::int => i), list1); |
| core::List<core::num> list2 = block { |
| final core::List<core::num> #t27 = <core::num>[]; |
| final core::Iterable<dynamic>? #t28 = dynamicList1 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>?; |
| if(!#t28.{core::Object::==}(null)) |
| for (final dynamic #t29 in #t28{core::Iterable<dynamic>}) { |
| final core::num #t30 = #t29 as{TypeError,ForNonNullableByDefault} core::num; |
| #t27.{core::List::add}{Invariant}(#t30); |
| } |
| final core::Iterable<dynamic>? #t31 = dynamicList2 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>?; |
| if(!#t31.{core::Object::==}(null)) |
| for (final dynamic #t32 in #t31{core::Iterable<dynamic>}) { |
| final core::num #t33 = #t32 as{TypeError,ForNonNullableByDefault} core::num; |
| #t27.{core::List::add}{Invariant}(#t33); |
| } |
| final core::Iterable<dynamic>? #t34 = dynamicList3 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>?; |
| if(!#t34.{core::Object::==}(null)) |
| for (final dynamic #t35 in #t34{core::Iterable<dynamic>}) { |
| final core::num #t36 = #t35 as{TypeError,ForNonNullableByDefault} core::num; |
| #t27.{core::List::add}{Invariant}(#t36); |
| } |
| final core::Iterable<core::num>? #t37 = iterableIntList; |
| if(!#t37.{core::Object::==}(null)) |
| #t27.{core::List::addAll}{Invariant}(#t37{core::Iterable<core::num>}); |
| final core::Iterable<core::num>? #t38 = intList; |
| if(!#t38.{core::Object::==}(null)) |
| #t27.{core::List::addAll}{Invariant}(#t38{core::Iterable<core::num>}); |
| } =>#t27; |
| self::expect(core::List::generate<core::num>(15, (core::int i) → core::int => i), list2); |
| } |
| static method main() → dynamic { |
| self::useAddAll(); |
| self::useAddAllNullable(); |
| } |
| static method expect(core::List<dynamic> list1, core::List<dynamic> list2) → void { |
| if(!list1.{core::List::length}.{core::num::==}(list2.{core::List::length})) { |
| throw "Unexpected length. Expected ${list1.{core::List::length}}, actual ${list2.{core::List::length}}."; |
| } |
| for (core::int i = 0; i.{core::num::<}(list1.{core::List::length}); i = i.{core::num::+}(1)) { |
| if(!list1.{core::List::[]}(i).{core::Object::==}(list2.{core::List::[]}(i))) { |
| throw "Unexpected element at index ${i}. Expected ${list1.{core::List::[]}(i)}, actual ${list2.{core::List::[]}(i)}."; |
| } |
| } |
| } |