blob: d1801f7deda5910c197db92b8b8796cf1b82a33f [file] [log] [blame]
library test;
//
// Problems in library:
//
// pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:17:44: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
// Try changing the type of the left hand side, or casting the right hand side to 'int'.
// int x = /*error:INVALID_ASSIGNMENT*/ i;
// ^
//
// pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:25:44: Error: A value of type 'T' can't be assigned to a variable of type 'int'.
// Try changing the type of the left hand side, or casting the right hand side to 'int'.
// int x = /*error:INVALID_ASSIGNMENT*/ i;
// ^
//
// pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:38: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_async.dart'.
// Try changing the type of the left hand side, or casting the right hand side to 'String'.
// String y = /*error:INVALID_ASSIGNMENT*/ x;
// ^
//
// pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:45:21: 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_async.dart'.
// Try changing the type of the variable.
// await for (String x in /*error:FOR_IN_OF_INVALID_ELEMENT_TYPE*/ myStream) {
// ^
//
// pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:66:74: Error: The type 'Map<String, Foo>' used in the 'for' loop must implement 'Stream<dynamic>'.
// - 'Map' is from 'dart:core'.
// - 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart'.
// - 'Stream' is from 'dart:async'.
// await for (var /*@type=dynamic*/ x in /*error:FOR_IN_OF_INVALID_TYPE*/ map) {
// ^
//
import self as self;
import "dart:core" as core;
import "dart:async" as asy;
class Foo extends core::Object {
field core::int bar = 42;
synthetic constructor •() self::Foo
: super core::Object::•()
;
}
class Bar<T extends asy::Stream<core::String> = asy::Stream<core::String>> extends core::Object {
synthetic constructor •() self::Bar<self::Bar::T>
: super core::Object::•()
;
method foo(generic-covariant-impl self::Bar::T t) dynamic async {
await for (core::String i in t) {
core::int x = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:17:44: Error: A value of type 'String' can't be assigned to a variable of type 'int'.
Try changing the type of the left hand side, or casting the right hand side to 'int'.
int x = /*error:INVALID_ASSIGNMENT*/ i;
^" in i as{TypeError} core::int;
}
}
}
class Baz<T extends core::Object = dynamic, E extends asy::Stream<self::Baz::T> = asy::Stream<dynamic>, S extends self::Baz::E = asy::Stream<dynamic>> extends core::Object {
synthetic constructor •() → self::Baz<self::Baz::T, self::Baz::E, self::Baz::S>
: super core::Object::•()
;
method foo(generic-covariant-impl self::Baz::S t) → dynamic async {
await for (self::Baz::T i in t) {
core::int x = let final<BottomType> #t2 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:25:44: Error: A value of type 'T' can't be assigned to a variable of type 'int'.
Try changing the type of the left hand side, or casting the right hand side to 'int'.
int x = /*error:INVALID_ASSIGNMENT*/ i;
^" in i as{TypeError} core::int;
self::Baz::T y = i;
}
}
}
abstract class MyStream<T extends core::Object = dynamic> extends asy::Stream<self::MyStream::T> {
static factory •<T extends core::Object = dynamic>() → self::MyStream<self::MyStream::•::T>
return null;
}
static method test() → dynamic async {
self::MyStream<self::Foo> myStream = self::MyStream::•<self::Foo>();
await for (self::Foo x in myStream) {
core::String y = let final<BottomType> #t3 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:38: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_async.dart'.
Try changing the type of the left hand side, or casting the right hand side to 'String'.
String y = /*error:INVALID_ASSIGNMENT*/ x;
^" in x as{TypeError} core::String;
}
await for (dynamic x in myStream) {
core::String y = x as{TypeError} core::String;
}
await for (final self::Foo #t4 in myStream) {
core::String x = let final<BottomType> #t5 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:45:21: 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_async.dart'.
Try changing the type of the variable.
await for (String x in /*error:FOR_IN_OF_INVALID_ELEMENT_TYPE*/ myStream) {
^" in #t4 as{TypeError} core::String;
core::String y = x;
}
dynamic z;
await for (final self::Foo #t6 in myStream) {
z = #t6;
core::String y = z as{TypeError} core::String;
}
asy::Stream<dynamic> stream = myStream;
await for (final dynamic #t7 in stream) {
self::Foo x = #t7 as{TypeError} self::Foo;
self::Foo y = x;
}
dynamic stream2 = myStream;
await for (final dynamic #t8 in stream2 as{TypeError} asy::Stream<dynamic>) {
self::Foo x = #t8 as{TypeError} self::Foo;
self::Foo y = x;
}
core::Map<core::String, self::Foo> map = <core::String, self::Foo>{};
await for (dynamic x in let final<BottomType> #t9 = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:66:74: Error: The type 'Map<String, Foo>' used in the 'for' loop must implement 'Stream<dynamic>'.
- 'Map' is from 'dart:core'.
- 'Foo' is from 'pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart'.
- 'Stream' is from 'dart:async'.
await for (var /*@type=dynamic*/ x in /*error:FOR_IN_OF_INVALID_TYPE*/ map) {
^" in map as{TypeError} asy::Stream<dynamic>) {
core::String y = x as{TypeError} core::String;
}
}
static method main() → dynamic {}