| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.src.task.strong.checker_test; | 5 library analyzer.test.src.task.strong.checker_test; |
| 6 | 6 |
| 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 8 | 8 |
| 9 import 'strong_test_helper.dart'; | 9 import 'strong_test_helper.dart'; |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 doSetUp(); | 33 doSetUp(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void tearDown() { | 36 void tearDown() { |
| 37 doTearDown(); | 37 doTearDown(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void test_awaitForInCastsStreamElementToVariable() { | 40 void test_awaitForInCastsStreamElementToVariable() { |
| 41 checkFile(''' | 41 checkFile(''' |
| 42 import 'dart:async'; | 42 import 'dart:async'; |
| 43 |
| 44 abstract class MyStream<T> extends Stream<T> { |
| 45 factory MyStream() => null; |
| 46 } |
| 47 |
| 43 main() async { | 48 main() async { |
| 44 // Don't choke if sequence is not stream. | 49 // Don't choke if sequence is not stream. |
| 45 await for (var i in /*error:FOR_IN_OF_INVALID_TYPE*/1234) {} | 50 await for (var i in /*error:FOR_IN_OF_INVALID_TYPE*/1234) {} |
| 46 | 51 |
| 47 // Dynamic cast. | 52 // Dynamic cast. |
| 48 await for (String /*info:DYNAMIC_CAST*/s in new Stream<dynamic>()) {} | 53 await for (String /*info:DYNAMIC_CAST*/s in new MyStream<dynamic>()) {} |
| 49 | 54 |
| 50 // Identity cast. | 55 // Identity cast. |
| 51 await for (String s in new Stream<String>()) {} | 56 await for (String s in new MyStream<String>()) {} |
| 52 | 57 |
| 53 // Untyped. | 58 // Untyped. |
| 54 await for (var s in new Stream<String>()) {} | 59 await for (var s in new MyStream<String>()) {} |
| 55 | 60 |
| 56 // Downcast. | 61 // Downcast. |
| 57 await for (int /*info:DOWN_CAST_IMPLICIT*/i in new Stream<num>()) {} | 62 await for (int /*info:DOWN_CAST_IMPLICIT*/i in new MyStream<num>()) {} |
| 58 } | 63 } |
| 59 '''); | 64 '''); |
| 60 } | 65 } |
| 61 | 66 |
| 62 void test_awaitForInCastsSupertypeSequenceToStream() { | 67 void test_awaitForInCastsSupertypeSequenceToStream() { |
| 63 checkFile(''' | 68 checkFile(''' |
| 64 main() async { | 69 main() async { |
| 65 dynamic d; | 70 dynamic d; |
| 66 await for (var i in /*info:DYNAMIC_CAST*/d) {} | 71 await for (var i in /*info:DYNAMIC_CAST*/d) {} |
| 67 | 72 |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 } | 979 } |
| 975 '''); | 980 '''); |
| 976 } | 981 } |
| 977 | 982 |
| 978 void test_functionModifiers_asyncStar() { | 983 void test_functionModifiers_asyncStar() { |
| 979 checkFile(''' | 984 checkFile(''' |
| 980 import 'dart:async'; | 985 import 'dart:async'; |
| 981 | 986 |
| 982 dynamic x; | 987 dynamic x; |
| 983 | 988 |
| 989 Stream<int> intStream; |
| 990 |
| 991 abstract class MyStream<T> extends Stream<T> { |
| 992 factory MyStream() => null; |
| 993 } |
| 994 |
| 984 bar1() async* { yield x; } | 995 bar1() async* { yield x; } |
| 985 Stream bar2() async* { yield x; } | 996 Stream bar2() async* { yield x; } |
| 986 Stream<int> bar3() async* { yield /*info:DYNAMIC_CAST*/x; } | 997 Stream<int> bar3() async* { yield /*info:DYNAMIC_CAST*/x; } |
| 987 Stream<int> bar4() async* { yield /*error:YIELD_OF_INVALID_TYPE*/new Stream<int>
(); } | 998 Stream<int> bar4() async* { yield /*error:YIELD_OF_INVALID_TYPE*/intStream; } |
| 988 | 999 |
| 989 baz1() async* { yield* /*info:DYNAMIC_CAST*/x; } | 1000 baz1() async* { yield* /*info:DYNAMIC_CAST*/x; } |
| 990 Stream baz2() async* { yield* /*info:DYNAMIC_CAST*/x; } | 1001 Stream baz2() async* { yield* /*info:DYNAMIC_CAST*/x; } |
| 991 Stream<int> baz3() async* { yield* /*info:DYNAMIC_CAST*/x; } | 1002 Stream<int> baz3() async* { yield* /*info:DYNAMIC_CAST*/x; } |
| 992 Stream<int> baz4() async* { yield* new Stream<int>(); } | 1003 Stream<int> baz4() async* { yield* intStream; } |
| 993 Stream<int> baz5() async* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new Stream()
; } | 1004 Stream<int> baz5() async* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new MyStream
(); } |
| 994 '''); | 1005 '''); |
| 995 } | 1006 } |
| 996 | 1007 |
| 997 void test_functionModifiers_syncStar() { | 1008 void test_functionModifiers_syncStar() { |
| 998 checkFile(''' | 1009 checkFile(''' |
| 999 dynamic x; | 1010 dynamic x; |
| 1000 | 1011 |
| 1001 bar1() sync* { yield x; } | 1012 bar1() sync* { yield x; } |
| 1002 Iterable bar2() sync* { yield x; } | 1013 Iterable bar2() sync* { yield x; } |
| 1003 Iterable<int> bar3() sync* { yield /*info:DYNAMIC_CAST*/x; } | 1014 Iterable<int> bar3() sync* { yield /*info:DYNAMIC_CAST*/x; } |
| (...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4027 // Regression test for https://github.com/dart-lang/sdk/issues/25069 | 4038 // Regression test for https://github.com/dart-lang/sdk/issues/25069 |
| 4028 checkFile(''' | 4039 checkFile(''' |
| 4029 typedef int Foo(); | 4040 typedef int Foo(); |
| 4030 void foo() {} | 4041 void foo() {} |
| 4031 void main () { | 4042 void main () { |
| 4032 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); | 4043 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); |
| 4033 } | 4044 } |
| 4034 '''); | 4045 '''); |
| 4035 } | 4046 } |
| 4036 } | 4047 } |
| OLD | NEW |