| library test /*isNonNullableByDefault*/; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:15:44: Error: A value of type 'String' can't be assigned to a variable of type 'int'. |
| // int x = /*error:INVALID_ASSIGNMENT*/ i; |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:23:44: Error: A value of type 'T' can't be assigned to a variable of type 'int'. |
| // int x = /*error:INVALID_ASSIGNMENT*/ i; |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:32:45: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'. |
| // - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'. |
| // String y = /*error:INVALID_ASSIGNMENT*/ x; |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:39:15: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'. |
| // - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'. |
| // Try changing the type of the variable. |
| // for (String x in /*error:FOR_IN_OF_INVALID_ELEMENT_TYPE*/ list) { |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:60:70: Error: The type 'Map<String, Foo>' used in the 'for' loop must implement 'Iterable<dynamic>'. |
| // - 'Map' is from 'dart:core'. |
| // - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'. |
| // - 'Iterable' is from 'dart:core'. |
| // for (var /*@ type=dynamic */ x in /*error:FOR_IN_OF_INVALID_TYPE*/ map) { |
| // ^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| |
| class Foo extends core::Object { |
| field core::int bar = 42; |
| synthetic constructor •() → self::Foo |
| : super core::Object::•() |
| ; |
| } |
| class Bar<T extends core::Iterable<core::String>> extends core::Object { |
| synthetic constructor •() → self::Bar<self::Bar::T> |
| : super core::Object::•() |
| ; |
| method foo(covariant-by-class self::Bar::T t) → void { |
| { |
| core::Iterator<core::String> :sync-for-iterator = t.{core::Iterable::iterator}{core::Iterator<core::String>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| core::String i = :sync-for-iterator.{core::Iterator::current}{core::String}; |
| { |
| core::int x = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:15:44: Error: A value of type 'String' can't be assigned to a variable of type 'int'. |
| int x = /*error:INVALID_ASSIGNMENT*/ i; |
| ^" in i as{TypeError,ForNonNullableByDefault} core::int; |
| } |
| } |
| } |
| } |
| } |
| class Baz<T extends core::Object? = dynamic, E extends core::Iterable<self::Baz::T%> = core::Iterable<dynamic>, S extends self::Baz::E = core::Iterable<dynamic>> extends core::Object { |
| synthetic constructor •() → self::Baz<self::Baz::T%, self::Baz::E, self::Baz::S> |
| : super core::Object::•() |
| ; |
| method foo(covariant-by-class self::Baz::S t) → void { |
| { |
| core::Iterator<self::Baz::T%> :sync-for-iterator = t.{core::Iterable::iterator}{core::Iterator<self::Baz::T%>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| self::Baz::T% i = :sync-for-iterator.{core::Iterator::current}{self::Baz::T%}; |
| { |
| core::int x = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:23:44: Error: A value of type 'T' can't be assigned to a variable of type 'int'. |
| int x = /*error:INVALID_ASSIGNMENT*/ i; |
| ^" in i as{TypeError,ForNonNullableByDefault} core::int; |
| self::Baz::T% y = i; |
| } |
| } |
| } |
| } |
| } |
| static method test() → dynamic { |
| core::List<self::Foo> list = core::_GrowableList::•<self::Foo>(0); |
| { |
| core::Iterator<self::Foo> :sync-for-iterator = list.{core::Iterable::iterator}{core::Iterator<self::Foo>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| self::Foo x = :sync-for-iterator.{core::Iterator::current}{self::Foo}; |
| { |
| core::String y = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:32:45: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'. |
| - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'. |
| String y = /*error:INVALID_ASSIGNMENT*/ x; |
| ^" in x as{TypeError,ForNonNullableByDefault} core::String; |
| } |
| } |
| } |
| { |
| core::Iterator<self::Foo> :sync-for-iterator = list.{core::Iterable::iterator}{core::Iterator<self::Foo>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| dynamic x = :sync-for-iterator.{core::Iterator::current}{self::Foo}; |
| { |
| core::String y = x as{TypeError,ForDynamic,ForNonNullableByDefault} core::String; |
| } |
| } |
| } |
| { |
| core::Iterator<self::Foo> :sync-for-iterator = list.{core::Iterable::iterator}{core::Iterator<self::Foo>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| final self::Foo #t1 = :sync-for-iterator.{core::Iterator::current}{self::Foo}; |
| { |
| core::String x = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:39:15: Error: A value of type 'Foo' can't be assigned to a variable of type 'String'. |
| - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'. |
| Try changing the type of the variable. |
| for (String x in /*error:FOR_IN_OF_INVALID_ELEMENT_TYPE*/ list) { |
| ^" in #t1 as{TypeError,ForNonNullableByDefault} core::String; |
| core::String y = x; |
| } |
| } |
| } |
| dynamic z; |
| { |
| core::Iterator<self::Foo> :sync-for-iterator = list.{core::Iterable::iterator}{core::Iterator<self::Foo>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| final self::Foo #t2 = :sync-for-iterator.{core::Iterator::current}{self::Foo}; |
| { |
| z = #t2; |
| core::String y = z as{TypeError,ForDynamic,ForNonNullableByDefault} core::String; |
| } |
| } |
| } |
| core::Iterable<dynamic> iter = list; |
| { |
| core::Iterator<dynamic> :sync-for-iterator = iter.{core::Iterable::iterator}{core::Iterator<dynamic>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| final dynamic #t3 = :sync-for-iterator.{core::Iterator::current}{dynamic}; |
| { |
| self::Foo x = #t3 as{TypeError,ForDynamic,ForNonNullableByDefault} self::Foo; |
| self::Foo y = x; |
| } |
| } |
| } |
| dynamic iter2 = list; |
| { |
| core::Iterator<dynamic> :sync-for-iterator = (iter2 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Iterable<dynamic>).{core::Iterable::iterator}{core::Iterator<dynamic>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| final dynamic #t4 = :sync-for-iterator.{core::Iterator::current}{dynamic}; |
| { |
| self::Foo x = #t4 as{TypeError,ForDynamic,ForNonNullableByDefault} self::Foo; |
| self::Foo y = x; |
| } |
| } |
| } |
| core::Map<core::String, self::Foo> map = <core::String, self::Foo>{}; |
| { |
| core::Iterator<Never> :sync-for-iterator = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart:60:70: Error: The type 'Map<String, Foo>' used in the 'for' loop must implement 'Iterable<dynamic>'. |
| - 'Map' is from 'dart:core'. |
| - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop.dart'. |
| - 'Iterable' is from 'dart:core'. |
| for (var /*@ type=dynamic */ x in /*error:FOR_IN_OF_INVALID_TYPE*/ map) { |
| ^" in map as{TypeError,ForNonNullableByDefault} core::Iterable<dynamic>.{core::Iterable::iterator}{core::Iterator<Never>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| dynamic x = :sync-for-iterator.{core::Iterator::current}{Never}; |
| { |
| core::String y = x as{TypeError,ForDynamic,ForNonNullableByDefault} core::String; |
| } |
| } |
| } |
| { |
| core::Iterator<core::String> :sync-for-iterator = map.{core::Map::keys}{core::Iterable<core::String>}.{core::Iterable::iterator}{core::Iterator<core::String>}; |
| for (; :sync-for-iterator.{core::Iterator::moveNext}(){() → core::bool}; ) { |
| core::String x = :sync-for-iterator.{core::Iterator::current}{core::String}; |
| { |
| core::String y = x; |
| } |
| } |
| } |
| } |
| static method main() → dynamic {} |