| 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 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x1 = (<dynamic>[])[0]; | 2471 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x1 = (<dynamic>[])[0]; |
| 2472 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x2, | 2472 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x2, |
| 2473 x3 = 42, | 2473 x3 = 42, |
| 2474 /*error:IMPLICIT_DYNAMIC_VARIABLE*/x4; | 2474 /*error:IMPLICIT_DYNAMIC_VARIABLE*/x4; |
| 2475 dynamic y0; | 2475 dynamic y0; |
| 2476 dynamic y1 = (<dynamic>[])[0]; | 2476 dynamic y1 = (<dynamic>[])[0]; |
| 2477 '''); | 2477 '''); |
| 2478 await check(implicitDynamic: false); | 2478 await check(implicitDynamic: false); |
| 2479 } | 2479 } |
| 2480 | 2480 |
| 2481 test_interfaceOverridesAreAllChecked() { |
| 2482 // Regression test for https://github.com/dart-lang/sdk/issues/29766 |
| 2483 return checkFile(r''' |
| 2484 class B { |
| 2485 set x(int y) {} |
| 2486 } |
| 2487 class C { |
| 2488 set x(Object y) {} |
| 2489 } |
| 2490 class D implements B, C { |
| 2491 /*error:INVALID_METHOD_OVERRIDE*/int x; |
| 2492 } |
| 2493 '''); |
| 2494 } |
| 2495 |
| 2496 test_interfacesFromMixinsAreChecked() { |
| 2497 // Regression test for https://github.com/dart-lang/sdk/issues/29782 |
| 2498 return checkFile(r''' |
| 2499 abstract class I { |
| 2500 set x(int v); |
| 2501 } |
| 2502 abstract class M implements I {} |
| 2503 |
| 2504 class C extends Object with M { |
| 2505 /*error:INVALID_METHOD_OVERRIDE*/String x; |
| 2506 } |
| 2507 |
| 2508 abstract class M2 = Object with M; |
| 2509 |
| 2510 class C2 extends Object with M2 { |
| 2511 /*error:INVALID_METHOD_OVERRIDE*/String x; |
| 2512 } |
| 2513 '''); |
| 2514 } |
| 2515 |
| 2516 test_interfacesFromMixinsUsedTwiceAreChecked() { |
| 2517 // Regression test for https://github.com/dart-lang/sdk/issues/29782 |
| 2518 return checkFile(r''' |
| 2519 abstract class I<E> { |
| 2520 set x(E v); |
| 2521 } |
| 2522 abstract class M<E> implements I<E> {} |
| 2523 |
| 2524 class C extends Object with M<int> { |
| 2525 /*error:INVALID_METHOD_OVERRIDE*/String x; |
| 2526 } |
| 2527 |
| 2528 abstract class D extends Object with M<num> {} |
| 2529 class E extends D with M<int> { |
| 2530 /*error:INVALID_METHOD_OVERRIDE*/int x; |
| 2531 } |
| 2532 class F extends D with M<int> { |
| 2533 num x; |
| 2534 } |
| 2535 '''); |
| 2536 } |
| 2537 |
| 2481 test_invalidOverrides_baseClassOverrideToChildInterface() async { | 2538 test_invalidOverrides_baseClassOverrideToChildInterface() async { |
| 2482 await checkFile(''' | 2539 await checkFile(''' |
| 2483 class A {} | 2540 class A {} |
| 2484 class B {} | 2541 class B {} |
| 2485 | 2542 |
| 2486 abstract class I { | 2543 abstract class I { |
| 2487 m(A a); | 2544 m(A a); |
| 2488 } | 2545 } |
| 2489 | 2546 |
| 2490 class Base { | 2547 class Base { |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3317 await checkFile(r''' | 3374 await checkFile(r''' |
| 3318 import 'meta.dart'; | 3375 import 'meta.dart'; |
| 3319 abstract class A { void test(A arg) { } } | 3376 abstract class A { void test(A arg) { } } |
| 3320 abstract class B extends A { void test(@checked B arg) { } } | 3377 abstract class B extends A { void test(@checked B arg) { } } |
| 3321 abstract class X implements A { } | 3378 abstract class X implements A { } |
| 3322 class C extends B with X { } | 3379 class C extends B with X { } |
| 3323 class D extends B implements A { } | 3380 class D extends B implements A { } |
| 3324 '''); | 3381 '''); |
| 3325 } | 3382 } |
| 3326 | 3383 |
| 3327 test_overrideNarrowsType_noDuplicateError() async { | 3384 test_overrideNarrowsType_noDuplicateError() { |
| 3328 // Regression test for https://github.com/dart-lang/sdk/issues/25232 | 3385 // Regression test for https://github.com/dart-lang/sdk/issues/25232 |
| 3329 _addMetaLibrary(); | 3386 return checkFile(r''' |
| 3330 await checkFile(r''' | |
| 3331 import 'meta.dart'; | |
| 3332 abstract class A { void test(A arg) { } } | 3387 abstract class A { void test(A arg) { } } |
| 3333 abstract class B extends A { | 3388 abstract class B extends A { |
| 3334 /*error:INVALID_METHOD_OVERRIDE*/void test(B arg) { } | 3389 /*error:INVALID_METHOD_OVERRIDE*/void test(B arg) { } |
| 3335 } | 3390 } |
| 3336 abstract class X implements A { } | 3391 abstract class X implements A { } |
| 3337 class C extends B with X { } | 3392 |
| 3393 class C extends B {} |
| 3394 |
| 3395 // We treat "with X" as asking for another check. |
| 3396 // This feels inconsistent. |
| 3397 class D /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends B with X { } |
| 3338 | 3398 |
| 3339 // We treat "implements A" as asking for another check. | 3399 // We treat "implements A" as asking for another check. |
| 3340 // This feels inconsistent to me. | 3400 // This feels inconsistent. |
| 3341 class D /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends B implements A { } | 3401 class E /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends B implements A { } |
| 3342 '''); | 3402 '''); |
| 3343 } | 3403 } |
| 3344 | 3404 |
| 3345 test_privateOverride() async { | 3405 test_privateOverride() async { |
| 3346 addFile(''' | 3406 addFile(''' |
| 3347 import 'main.dart' as main; | 3407 import 'main.dart' as main; |
| 3348 | 3408 |
| 3349 class Base { | 3409 class Base { |
| 3350 var f1; | 3410 var f1; |
| 3351 var _f2; | 3411 var _f2; |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4201 class CheckerTest_Driver extends CheckerTest { | 4261 class CheckerTest_Driver extends CheckerTest { |
| 4202 @override | 4262 @override |
| 4203 bool get enableNewAnalysisDriver => true; | 4263 bool get enableNewAnalysisDriver => true; |
| 4204 | 4264 |
| 4205 @failingTest | 4265 @failingTest |
| 4206 @override | 4266 @override |
| 4207 test_covariantOverride_fields() async { | 4267 test_covariantOverride_fields() async { |
| 4208 await super.test_covariantOverride_fields(); | 4268 await super.test_covariantOverride_fields(); |
| 4209 } | 4269 } |
| 4210 } | 4270 } |
| OLD | NEW |