| Index: tests/compiler/dart2js/type_checker_test.dart
|
| diff --git a/tests/compiler/dart2js/type_checker_test.dart b/tests/compiler/dart2js/type_checker_test.dart
|
| index 61955d443ea1e89edff531993e03abcb9fe1a8fd..0e6a54ea5b583fddaa7ee9249fdda9b81409c231 100644
|
| --- a/tests/compiler/dart2js/type_checker_test.dart
|
| +++ b/tests/compiler/dart2js/type_checker_test.dart
|
| @@ -35,6 +35,7 @@ main() {
|
| testReturn,
|
| testFor,
|
| testSyncForIn,
|
| + testAsyncForIn,
|
| testWhile,
|
| testTry,
|
| testSwitch,
|
| @@ -284,6 +285,144 @@ class Class {
|
| }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| }
|
|
|
| +testAsyncForIn(MockCompiler compiler) {
|
| + String script = """
|
| +abstract class CustomStream<T> implements Stream<T> {}
|
| +abstract class StringStream implements Stream<String> {}
|
| +
|
| +var topLevelDyn;
|
| +String topLevelString;
|
| +int topLevelInt;
|
| +
|
| +class Class {
|
| + void forIn() async {}
|
| +
|
| + var instanceDyn;
|
| + String instanceString;
|
| + int instanceInt;
|
| +
|
| + static var staticDyn;
|
| + static String staticString;
|
| + static int staticInt;
|
| +}
|
| +""";
|
| + compiler.parseScript(script);
|
| + ClassElement foo = compiler.mainApp.find("Class");
|
| + foo.ensureResolved(compiler);
|
| + FunctionElement method = foo.lookupLocalMember('forIn');
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + var stream;
|
| + await for (var e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + var stream;
|
| + await for (String e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + var stream;
|
| + await for (int e in stream) {}
|
| + }""");
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + await for (var e in []) {}
|
| + }""", hints: MessageKind.NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (var e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (String e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (int e in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + CustomStream<String> stream;
|
| + await for (var e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + CustomStream<String> stream;
|
| + await for (String e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + CustomStream<String> stream;
|
| + await for (int e in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + StringStream stream;
|
| + await for (var e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + StringStream stream;
|
| + await for (String e in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + StringStream stream;
|
| + await for (int e in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + var localDyn;
|
| + await for (localDyn in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + String localString;
|
| + await for (localString in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + int localInt;
|
| + await for (localInt in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (topLevelDyn in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (topLevelString in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (topLevelInt in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (instanceDyn in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (instanceString in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (instanceInt in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (staticDyn in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (staticString in stream) {}
|
| + }""");
|
| + analyzeIn(compiler, method, """{
|
| + Stream<String> stream;
|
| + await for (staticInt in stream) {}
|
| + }""", hints: MessageKind.FORIN_NOT_ASSIGNABLE);
|
| +}
|
| +
|
|
|
| testWhile(MockCompiler compiler) {
|
| check(String code, {warnings}) {
|
|
|