| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.static_type_warning_code_test; | 5 library analyzer.test.generated.static_type_warning_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 8 import 'package:analyzer/src/error/codes.dart'; | 8 import 'package:analyzer/src/error/codes.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/java_core.dart' show formatList; | 10 import 'package:analyzer/src/generated/java_core.dart' show formatList; |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 | 1114 |
| 1115 test_returnOfInvalidType_expressionFunctionBody_method() async { | 1115 test_returnOfInvalidType_expressionFunctionBody_method() async { |
| 1116 await assertErrorsInCode( | 1116 await assertErrorsInCode( |
| 1117 r''' | 1117 r''' |
| 1118 class A { | 1118 class A { |
| 1119 int f() => '0'; | 1119 int f() => '0'; |
| 1120 }''', | 1120 }''', |
| 1121 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 1121 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 test_returnOfInvalidType_not_issued_for_expressionFunctionBody_void() async { | |
| 1125 await assertNoErrorsInCode("void f() => 42;"); | |
| 1126 } | |
| 1127 | |
| 1128 test_returnOfInvalidType_function() async { | 1124 test_returnOfInvalidType_function() async { |
| 1129 await assertErrorsInCode("int f() { return '0'; }", | 1125 await assertErrorsInCode("int f() { return '0'; }", |
| 1130 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 1126 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 1131 } | 1127 } |
| 1132 | 1128 |
| 1133 test_returnOfInvalidType_getter() async { | 1129 test_returnOfInvalidType_getter() async { |
| 1134 await assertErrorsInCode("int get g { return '0'; }", | 1130 await assertErrorsInCode("int get g { return '0'; }", |
| 1135 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 1131 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 1136 } | 1132 } |
| 1137 | 1133 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1149 | 1145 |
| 1150 test_returnOfInvalidType_method() async { | 1146 test_returnOfInvalidType_method() async { |
| 1151 await assertErrorsInCode( | 1147 await assertErrorsInCode( |
| 1152 r''' | 1148 r''' |
| 1153 class A { | 1149 class A { |
| 1154 int f() { return '0'; } | 1150 int f() { return '0'; } |
| 1155 }''', | 1151 }''', |
| 1156 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 1152 [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 1157 } | 1153 } |
| 1158 | 1154 |
| 1155 test_returnOfInvalidType_not_issued_for_expressionFunctionBody_void() async { |
| 1156 await assertNoErrorsInCode("void f() => 42;"); |
| 1157 } |
| 1158 |
| 1159 test_returnOfInvalidType_not_issued_for_valid_generic_return() async { | 1159 test_returnOfInvalidType_not_issued_for_valid_generic_return() async { |
| 1160 await assertNoErrorsInCode(r''' | 1160 await assertNoErrorsInCode(r''' |
| 1161 abstract class F<T, U> { | 1161 abstract class F<T, U> { |
| 1162 U get value; | 1162 U get value; |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 abstract class G<T> { | 1165 abstract class G<T> { |
| 1166 T test(F<int, T> arg) => arg.value; | 1166 T test(F<int, T> arg) => arg.value; |
| 1167 } | 1167 } |
| 1168 | 1168 |
| (...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 Object f3() sync* { yield 42; } | 2479 Object f3() sync* { yield 42; } |
| 2480 Iterable f4() sync* { yield 42; } | 2480 Iterable f4() sync* { yield 42; } |
| 2481 Iterable<dynamic> f5() sync* { yield 42; } | 2481 Iterable<dynamic> f5() sync* { yield 42; } |
| 2482 Iterable<Object> f6() sync* { yield 42; } | 2482 Iterable<Object> f6() sync* { yield 42; } |
| 2483 Iterable<num> f7() sync* { yield 42; } | 2483 Iterable<num> f7() sync* { yield 42; } |
| 2484 Iterable<int> f8() sync* { yield 42; } | 2484 Iterable<int> f8() sync* { yield 42; } |
| 2485 ''', | 2485 ''', |
| 2486 []); | 2486 []); |
| 2487 } | 2487 } |
| 2488 } | 2488 } |
| OLD | NEW |