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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 | 440 |
441 void main() { | 441 void main() { |
442 A a = new A.c2(/*info:DOWN_CAST_IMPLICIT*/z, /*error:ARGUMENT_TYPE_NOT_ASSIGN
ABLE*/z); | 442 A a = new A.c2(/*info:DOWN_CAST_IMPLICIT*/z, /*error:ARGUMENT_TYPE_NOT_ASSIGN
ABLE*/z); |
443 var b = new B.c2(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*info:DOWN_C
AST_IMPLICIT*/obj); | 443 var b = new B.c2(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/"hello", /*info:DOWN_C
AST_IMPLICIT*/obj); |
444 } | 444 } |
445 '''); | 445 '''); |
446 } | 446 } |
447 | 447 |
448 test_conversionAndDynamicInvoke() async { | 448 test_conversionAndDynamicInvoke() async { |
449 addFile( | 449 addFile(''' |
450 ''' | |
451 dynamic toString = (int x) => x + 42; | 450 dynamic toString = (int x) => x + 42; |
452 dynamic hashCode = "hello"; | 451 dynamic hashCode = "hello"; |
453 ''', | 452 ''', name: '/helper.dart'); |
454 name: '/helper.dart'); | |
455 await checkFile(''' | 453 await checkFile(''' |
456 import 'helper.dart' as helper; | 454 import 'helper.dart' as helper; |
457 | 455 |
458 class A { | 456 class A { |
459 String x = "hello world"; | 457 String x = "hello world"; |
460 | 458 |
461 void baz1(y) { x + /*info:DYNAMIC_CAST*/y; } | 459 void baz1(y) { x + /*info:DYNAMIC_CAST*/y; } |
462 static baz2(y) => /*info:DYNAMIC_INVOKE*/y + y; | 460 static baz2(y) => /*info:DYNAMIC_INVOKE*/y + y; |
463 } | 461 } |
464 | 462 |
(...skipping 2873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 abstract class X implements A { } | 3336 abstract class X implements A { } |
3339 class C extends B with X { } | 3337 class C extends B with X { } |
3340 | 3338 |
3341 // We treat "implements A" as asking for another check. | 3339 // We treat "implements A" as asking for another check. |
3342 // This feels inconsistent to me. | 3340 // This feels inconsistent to me. |
3343 class D /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends B implements A { } | 3341 class D /*error:INVALID_METHOD_OVERRIDE_FROM_BASE*/extends B implements A { } |
3344 '''); | 3342 '''); |
3345 } | 3343 } |
3346 | 3344 |
3347 test_privateOverride() async { | 3345 test_privateOverride() async { |
3348 addFile( | 3346 addFile(''' |
3349 ''' | |
3350 import 'main.dart' as main; | 3347 import 'main.dart' as main; |
3351 | 3348 |
3352 class Base { | 3349 class Base { |
3353 var f1; | 3350 var f1; |
3354 var _f2; | 3351 var _f2; |
3355 var _f3; | 3352 var _f3; |
3356 get _f4 => null; | 3353 get _f4 => null; |
3357 | 3354 |
3358 int _m1() => null; | 3355 int _m1() => null; |
3359 } | 3356 } |
3360 | 3357 |
3361 class GrandChild extends main.Child { | 3358 class GrandChild extends main.Child { |
3362 var _f2; | 3359 var _f2; |
3363 var _f3; | 3360 var _f3; |
3364 var _f4; | 3361 var _f4; |
3365 | 3362 |
3366 /*error:INVALID_METHOD_OVERRIDE*/String _m1() => null; | 3363 /*error:INVALID_METHOD_OVERRIDE*/String _m1() => null; |
3367 } | 3364 } |
3368 ''', | 3365 ''', name: '/helper.dart'); |
3369 name: '/helper.dart'); | |
3370 await checkFile(''' | 3366 await checkFile(''' |
3371 import 'helper.dart' as helper; | 3367 import 'helper.dart' as helper; |
3372 | 3368 |
3373 class Child extends helper.Base { | 3369 class Child extends helper.Base { |
3374 var f1; | 3370 var f1; |
3375 var _f2; | 3371 var _f2; |
3376 var _f4; | 3372 var _f4; |
3377 | 3373 |
3378 String _m1() => null; | 3374 String _m1() => null; |
3379 } | 3375 } |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4183 await checkFile(''' | 4179 await checkFile(''' |
4184 typedef int Foo(); | 4180 typedef int Foo(); |
4185 void foo() {} | 4181 void foo() {} |
4186 void main () { | 4182 void main () { |
4187 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); | 4183 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); |
4188 } | 4184 } |
4189 '''); | 4185 '''); |
4190 } | 4186 } |
4191 | 4187 |
4192 void _addMetaLibrary() { | 4188 void _addMetaLibrary() { |
4193 addFile( | 4189 addFile(r''' |
4194 r''' | |
4195 library meta; | 4190 library meta; |
4196 class _Checked { const _Checked(); } | 4191 class _Checked { const _Checked(); } |
4197 const Object checked = const _Checked(); | 4192 const Object checked = const _Checked(); |
4198 | 4193 |
4199 class _Virtual { const _Virtual(); } | 4194 class _Virtual { const _Virtual(); } |
4200 const Object virtual = const _Virtual(); | 4195 const Object virtual = const _Virtual(); |
4201 ''', | 4196 ''', name: '/meta.dart'); |
4202 name: '/meta.dart'); | |
4203 } | 4197 } |
4204 } | 4198 } |
4205 | 4199 |
4206 @reflectiveTest | 4200 @reflectiveTest |
4207 class CheckerTest_Driver extends CheckerTest { | 4201 class CheckerTest_Driver extends CheckerTest { |
4208 @override | 4202 @override |
4209 bool get enableNewAnalysisDriver => true; | 4203 bool get enableNewAnalysisDriver => true; |
4210 | 4204 |
4211 @failingTest | 4205 @failingTest |
4212 @override | 4206 @override |
4213 test_covariantOverride_fields() async { | 4207 test_covariantOverride_fields() async { |
4214 await super.test_covariantOverride_fields(); | 4208 await super.test_covariantOverride_fields(); |
4215 } | 4209 } |
4216 } | 4210 } |
OLD | NEW |