blob: 6dc3fe7371d433ad0452fadff621e9e2e0a7aed6 [file] [log] [blame]
library test /*isNonNullableByDefault*/;
//
// 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'.
// 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'.
// 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'.
// 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:76: 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;
import "dart:async";
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>> extends core::Object {
synthetic constructor •() self::Bar<self::Bar::T>
: super core::Object::•()
;
method foo(covariant-by-class self::Bar::T t) dynamic async /* futureValueType= dynamic */ {
{
self::Bar::T :stream = t;
asy::_StreamIterator<core::String>? :for-iterator = new asy::_StreamIterator::•<core::String>(:stream);
try
while (let dynamic #t1 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
core::String i = :for-iterator.{asy::_StreamIterator::current}{core::String};
{
core::int x = 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'.
int x = /*error:INVALID_ASSIGNMENT*/ i;
^" in i as{TypeError,ForNonNullableByDefault} core::int;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<core::String>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
}
}
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(covariant-by-class self::Baz::S t) dynamic async /* futureValueType= dynamic */ {
{
self::Baz::S :stream = t;
asy::_StreamIterator<self::Baz::T%>? :for-iterator = new asy::_StreamIterator::•<self::Baz::T%>(:stream);
try
while (let dynamic #t2 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
self::Baz::T% i = :for-iterator.{asy::_StreamIterator::current}{self::Baz::T%};
{
core::int x = 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'.
int x = /*error:INVALID_ASSIGNMENT*/ i;
^" in i as{TypeError,ForNonNullableByDefault} core::int;
self::Baz::T% y = i;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<self::Baz::T%>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
}
}
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 throw "";
}
static method test() dynamic async /* futureValueType= dynamic */ {
self::MyStream<self::Foo> myStream = self::MyStream::•<self::Foo>();
{
self::MyStream<self::Foo> :stream = myStream;
asy::_StreamIterator<self::Foo>? :for-iterator = new asy::_StreamIterator::•<self::Foo>(:stream);
try
while (let dynamic #t3 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
self::Foo x = :for-iterator.{asy::_StreamIterator::current}{self::Foo};
{
core::String y = 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'.
String y = /*error:INVALID_ASSIGNMENT*/ x;
^" in x as{TypeError,ForNonNullableByDefault} core::String;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<self::Foo>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
{
self::MyStream<self::Foo> :stream = myStream;
asy::_StreamIterator<dynamic>? :for-iterator = new asy::_StreamIterator::•<dynamic>(:stream);
try
while (let dynamic #t4 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
dynamic x = :for-iterator.{asy::_StreamIterator::current}{dynamic};
{
core::String y = x as{TypeError,ForDynamic,ForNonNullableByDefault} core::String;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<dynamic>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
{
self::MyStream<self::Foo> :stream = myStream;
asy::_StreamIterator<self::Foo>? :for-iterator = new asy::_StreamIterator::•<self::Foo>(:stream);
try
while (let dynamic #t5 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
final self::Foo #t6 = :for-iterator.{asy::_StreamIterator::current}{self::Foo};
{
core::String x = 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 #t6 as{TypeError,ForNonNullableByDefault} core::String;
core::String y = x;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<self::Foo>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
dynamic z;
{
self::MyStream<self::Foo> :stream = myStream;
asy::_StreamIterator<self::Foo>? :for-iterator = new asy::_StreamIterator::•<self::Foo>(:stream);
try
while (let dynamic #t7 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
final self::Foo #t8 = :for-iterator.{asy::_StreamIterator::current}{self::Foo};
{
z = #t8;
core::String y = z as{TypeError,ForDynamic,ForNonNullableByDefault} core::String;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<self::Foo>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
asy::Stream<dynamic> stream = myStream;
{
asy::Stream<dynamic> :stream = stream;
asy::_StreamIterator<dynamic>? :for-iterator = new asy::_StreamIterator::•<dynamic>(:stream);
try
while (let dynamic #t9 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
final dynamic #t10 = :for-iterator.{asy::_StreamIterator::current}{dynamic};
{
self::Foo x = #t10 as{TypeError,ForDynamic,ForNonNullableByDefault} self::Foo;
self::Foo y = x;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<dynamic>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
dynamic stream2 = myStream;
{
asy::Stream<dynamic> :stream = stream2 as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Stream<dynamic>;
asy::_StreamIterator<dynamic>? :for-iterator = new asy::_StreamIterator::•<dynamic>(:stream);
try
while (let dynamic #t11 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
final dynamic #t12 = :for-iterator.{asy::_StreamIterator::current}{dynamic};
{
self::Foo x = #t12 as{TypeError,ForDynamic,ForNonNullableByDefault} self::Foo;
self::Foo y = x;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<dynamic>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
core::Map<core::String, self::Foo> map = <core::String, self::Foo>{};
{
Never :stream = invalid-expression "pkg/front_end/testcases/inference/infer_types_on_loop_indices_for_each_loop_async.dart:66:76: 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,ForNonNullableByDefault} asy::Stream<dynamic>;
asy::_StreamIterator<dynamic>? :for-iterator = new asy::_StreamIterator::•<dynamic>(:stream);
try
while (let dynamic #t13 = asy::_asyncStarMoveNextHelper(:stream) in await :for-iterator.{asy::_StreamIterator::moveNext}(){() → asy::Future<core::bool>}) {
dynamic x = :for-iterator.{asy::_StreamIterator::current}{dynamic};
{
core::String y = x as{TypeError,ForDynamic,ForNonNullableByDefault} core::String;
}
}
finally
if(!(:for-iterator.{asy::_StreamIterator::_subscription}{asy::StreamSubscription<dynamic>?} == null))
await :for-iterator.{asy::_StreamIterator::cancel}(){() asy::Future<dynamic>};
}
}
static method main() dynamic {}