| 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 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2189   do {} while (/*error:NON_BOOL_CONDITION*/i); | 2189   do {} while (/*error:NON_BOOL_CONDITION*/i); | 
| 2190 | 2190 | 
| 2191   for (;b;) {} | 2191   for (;b;) {} | 
| 2192   for (;/*info:DYNAMIC_CAST*/dyn;) {} | 2192   for (;/*info:DYNAMIC_CAST*/dyn;) {} | 
| 2193   for (;/*info:DOWN_CAST_IMPLICIT*/obj;) {} | 2193   for (;/*info:DOWN_CAST_IMPLICIT*/obj;) {} | 
| 2194   for (;/*error:NON_BOOL_CONDITION*/i;) {} | 2194   for (;/*error:NON_BOOL_CONDITION*/i;) {} | 
| 2195 } | 2195 } | 
| 2196 '''); | 2196 '''); | 
| 2197   } | 2197   } | 
| 2198 | 2198 | 
| 2199   test_implicitCasts() async { | 2199   test_implicitCasts_assignment() async { | 
| 2200     addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;'); | 2200     addFile( | 
|  | 2201         'num n; int i; void main() { i = /*info:DOWN_CAST_IMPLICIT*/n;}//yy'); | 
| 2201     await check(); | 2202     await check(); | 
| 2202     addFile('num n; int i = /*error:INVALID_ASSIGNMENT*/n;'); | 2203     addFile( | 
| 2203     await check(implicitCasts: false); | 2204         'num n; int i; void main() { i = /*error:INVALID_ASSIGNMENT*/n;}//ny'); | 
|  | 2205     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2206     addFile( | 
|  | 2207         'num n; int i; void main() { i = /*info:DOWN_CAST_IMPLICIT*/n;}//yn'); | 
|  | 2208     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2209     addFile( | 
|  | 2210         'num n; int i; void main() { i = /*error:INVALID_ASSIGNMENT*/n;}//nn'); | 
|  | 2211     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2212   } | 
|  | 2213 | 
|  | 2214   test_implicitCasts_compoundAssignment() async { | 
|  | 2215     addFile('''f(num n, int i) { | 
|  | 2216                /*info:DOWN_CAST_IMPLICIT_ASSIGN*/i += n;}//yy'''); | 
|  | 2217     await check(); | 
|  | 2218     addFile('''f(num n, int i) { | 
|  | 2219                i += /*error:INVALID_ASSIGNMENT*/n;}//ny'''); | 
|  | 2220     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2221     addFile('''f(num n, int i) { | 
|  | 2222                /*info:DOWN_CAST_IMPLICIT_ASSIGN*/i += n;}//yn'''); | 
|  | 2223     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2224     addFile('''f(num n, int i) { | 
|  | 2225                i += /*error:INVALID_ASSIGNMENT*/n;}//nn'''); | 
|  | 2226     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2227   } | 
|  | 2228 | 
|  | 2229   test_implicitCasts_constructorInitializer() async { | 
|  | 2230     addFile( | 
|  | 2231         'class A { int i; A(num n) : i = /*info:DOWN_CAST_IMPLICIT*/n;}//yy'); | 
|  | 2232     await check(); | 
|  | 2233     addFile( | 
|  | 2234         'class A { int i; A(num n) : i = /*error:FIELD_INITIALIZER_NOT_ASSIGNABL
      E*/n;}//ny'); | 
|  | 2235     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2236     addFile( | 
|  | 2237         'class A { int i; A(num n) : i = /*info:DOWN_CAST_IMPLICIT*/n;}//yn'); | 
|  | 2238     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2239     addFile( | 
|  | 2240         'class A { int i; A(num n) : i = /*error:FIELD_INITIALIZER_NOT_ASSIGNABL
      E*/n;}//nn'); | 
|  | 2241     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2242   } | 
|  | 2243 | 
|  | 2244   test_implicitCasts_defaultValue() async { | 
|  | 2245     addFile('''const num n = 0; | 
|  | 2246                f({int i = /*info:DOWN_CAST_IMPLICIT*/n}) => i;//yy'''); | 
|  | 2247     await check(); | 
|  | 2248     addFile('''const num n = 0; | 
|  | 2249                f({int i = /*error:INVALID_ASSIGNMENT*/n}) => i;//ny'''); | 
|  | 2250     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2251     addFile('''const num n = 0; | 
|  | 2252                f({int i = /*info:DOWN_CAST_IMPLICIT*/n}) => i;//yn'''); | 
|  | 2253     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2254     addFile('''const num n = 0; | 
|  | 2255                f({int i = /*error:INVALID_ASSIGNMENT*/n}) => i;//nn'''); | 
|  | 2256     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2257   } | 
|  | 2258 | 
|  | 2259   test_implicitCasts_fieldInitializer() async { | 
|  | 2260     addFile('class A { static num n; int i = /*info:ASSIGNMENT_CAST*/n;}//yy'); | 
|  | 2261     await check(); | 
|  | 2262     addFile('class A { static num n; int i = /*info:ASSIGNMENT_CAST*/n;}//ny'); | 
|  | 2263     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2264     addFile( | 
|  | 2265         'class A { static num n; int i = /*error:INVALID_ASSIGNMENT*/n;}//yn'); | 
|  | 2266     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2267     addFile( | 
|  | 2268         'class A { static num n; int i = /*error:INVALID_ASSIGNMENT*/n;}//nn'); | 
|  | 2269     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2270   } | 
|  | 2271 | 
|  | 2272   test_implicitCasts_functionCall() async { | 
|  | 2273     addFile('''num n; | 
|  | 2274                f(int i) => i; | 
|  | 2275                var i = f(/*info:DOWN_CAST_IMPLICIT*/n);//yy'''); | 
|  | 2276     await check(); | 
|  | 2277     addFile('''num n; | 
|  | 2278                f(int i) => i; | 
|  | 2279                var i = f(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/n);//ny'''); | 
|  | 2280     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2281     addFile('''num n; | 
|  | 2282                f(int i) => i; | 
|  | 2283                var i = f(/*info:DOWN_CAST_IMPLICIT*/n);//yn'''); | 
|  | 2284     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2285     addFile('''num n; | 
|  | 2286              f(int i) => i; | 
|  | 2287              var i = f(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/n);//nn'''); | 
|  | 2288     await check(implicitCasts: false, declarationCasts: false); | 
| 2204   } | 2289   } | 
| 2205 | 2290 | 
| 2206   test_implicitCasts_genericMethods() async { | 2291   test_implicitCasts_genericMethods() async { | 
| 2207     addFile(''' | 2292     addFile(''' | 
| 2208 var x = <String>[].map<String>((x) => ""); | 2293 var x = <String>[].map<String>((x) => ""); | 
| 2209 '''); | 2294 '''); | 
| 2210     await check(implicitCasts: false); | 2295     await check(implicitCasts: false); | 
| 2211   } | 2296   } | 
| 2212 | 2297 | 
|  | 2298   test_implicitCasts_initializer() async { | 
|  | 2299     addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;//yy'); | 
|  | 2300     await check(); | 
|  | 2301     addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;//ny'); | 
|  | 2302     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2303     addFile('num n; int i = /*error:INVALID_ASSIGNMENT*/n;//yn'); | 
|  | 2304     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2305     addFile('num n; int i = /*error:INVALID_ASSIGNMENT*/n;//nn'); | 
|  | 2306     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2307   } | 
|  | 2308 | 
| 2213   test_implicitCasts_numericOps() async { | 2309   test_implicitCasts_numericOps() async { | 
| 2214     // Regression test for https://github.com/dart-lang/sdk/issues/26912 | 2310     // Regression test for https://github.com/dart-lang/sdk/issues/26912 | 
| 2215     addFile(r''' | 2311     addFile(r''' | 
| 2216 void f() { | 2312 void f() { | 
| 2217   int x = 0; | 2313   int x = 0; | 
| 2218   int y = 0; | 2314   int y = 0; | 
| 2219   x += y; | 2315   x += y; | 
| 2220 } | 2316 } | 
| 2221     '''); | 2317     '''); | 
| 2222     await check(implicitCasts: false); | 2318     await check(implicitCasts: false); | 
| 2223   } | 2319   } | 
| 2224 | 2320 | 
|  | 2321   test_implicitCasts_operator() async { | 
|  | 2322     addFile('''num n; | 
|  | 2323              int i; | 
|  | 2324              var r = i & /*info:DOWN_CAST_IMPLICIT*/n;//yy'''); | 
|  | 2325     await check(); | 
|  | 2326     addFile('''num n; | 
|  | 2327              int i; | 
|  | 2328              var r = i & /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/n;//ny'''); | 
|  | 2329     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2330     addFile('''num n; | 
|  | 2331              int i; | 
|  | 2332              var r = i & /*info:DOWN_CAST_IMPLICIT*/n;//yn'''); | 
|  | 2333     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2334     addFile('''num n; | 
|  | 2335              int i; | 
|  | 2336              var r = i & /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/n;//nn'''); | 
|  | 2337     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2338   } | 
|  | 2339 | 
| 2225   test_implicitCasts_return() async { | 2340   test_implicitCasts_return() async { | 
|  | 2341     addFile('int f(num n) => /*info:DOWN_CAST_IMPLICIT*/n;//yy'); | 
|  | 2342     await check(); | 
|  | 2343     addFile('int f(num n) => /*error:RETURN_OF_INVALID_TYPE*/n;//ny'); | 
|  | 2344     await check(implicitCasts: false, declarationCasts: true); | 
|  | 2345     addFile('int f(num n) => /*info:DOWN_CAST_IMPLICIT*/n;//yn'); | 
|  | 2346     await check(implicitCasts: true, declarationCasts: false); | 
|  | 2347     addFile('int f(num n) => /*error:RETURN_OF_INVALID_TYPE*/n;//nn'); | 
|  | 2348     await check(implicitCasts: false, declarationCasts: false); | 
|  | 2349   } | 
|  | 2350 | 
|  | 2351   test_implicitCasts_return_async() async { | 
| 2226     addFile(r''' | 2352     addFile(r''' | 
| 2227 import 'dart:async'; | 2353 import 'dart:async'; | 
| 2228 | 2354 | 
| 2229 Future<List<String>> foo() async { | 2355 Future<List<String>> foo() async { | 
| 2230   List<Object> x = <Object>["hello", "world"]; | 2356   List<Object> x = <Object>["hello", "world"]; | 
| 2231   return /*info:DOWN_CAST_IMPLICIT*/x; | 2357   return /*info:DOWN_CAST_IMPLICIT*/x; | 
| 2232 } | 2358 } | 
| 2233     '''); | 2359     '''); | 
| 2234     await check(); | 2360     await check(); | 
| 2235   } | 2361   } | 
| (...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4201 class CheckerTest_Driver extends CheckerTest { | 4327 class CheckerTest_Driver extends CheckerTest { | 
| 4202   @override | 4328   @override | 
| 4203   bool get enableNewAnalysisDriver => true; | 4329   bool get enableNewAnalysisDriver => true; | 
| 4204 | 4330 | 
| 4205   @failingTest | 4331   @failingTest | 
| 4206   @override | 4332   @override | 
| 4207   test_covariantOverride_fields() async { | 4333   test_covariantOverride_fields() async { | 
| 4208     await super.test_covariantOverride_fields(); | 4334     await super.test_covariantOverride_fields(); | 
| 4209   } | 4335   } | 
| 4210 } | 4336 } | 
| OLD | NEW | 
|---|