| 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_warning_code_test; | 5 library analyzer.test.generated.static_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/source_io.dart'; | 10 import 'package:analyzer/src/generated/source_io.dart'; |
| (...skipping 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 class A {}''', | 3366 class A {}''', |
| 3367 r''' | 3367 r''' |
| 3368 library root; | 3368 library root; |
| 3369 import 'lib1.dart' deferred as a; | 3369 import 'lib1.dart' deferred as a; |
| 3370 a.A v;''' | 3370 a.A v;''' |
| 3371 ], <ErrorCode>[ | 3371 ], <ErrorCode>[ |
| 3372 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS | 3372 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS |
| 3373 ]); | 3373 ]); |
| 3374 } | 3374 } |
| 3375 | 3375 |
| 3376 void test_typeAnnotationGenericFunctionParameter_localFunction() { |
| 3377 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); |
| 3378 Source source = addSource(r''' |
| 3379 class A { |
| 3380 void method() { |
| 3381 T local<T>(Object t) { |
| 3382 return (t is T) ? t : null; |
| 3383 } |
| 3384 } |
| 3385 }'''); |
| 3386 computeLibrarySourceErrors(source); |
| 3387 assertErrors( |
| 3388 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); |
| 3389 verify([source]); |
| 3390 } |
| 3391 |
| 3392 void test_typeAnnotationGenericFunctionParameter_method() { |
| 3393 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); |
| 3394 Source source = addSource(r''' |
| 3395 class A { |
| 3396 T method<T>(Object t) { |
| 3397 return (t is T) ? t : null; |
| 3398 } |
| 3399 }'''); |
| 3400 computeLibrarySourceErrors(source); |
| 3401 assertErrors( |
| 3402 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); |
| 3403 verify([source]); |
| 3404 } |
| 3405 |
| 3406 void test_typeAnnotationGenericFunctionParameter_topLevelFunction() { |
| 3407 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); |
| 3408 Source source = addSource(r''' |
| 3409 T function<T>(Object t) { |
| 3410 return (t is T) ? t : null; |
| 3411 }'''); |
| 3412 computeLibrarySourceErrors(source); |
| 3413 assertErrors( |
| 3414 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); |
| 3415 verify([source]); |
| 3416 } |
| 3417 |
| 3376 void test_typeParameterReferencedByStatic_field() { | 3418 void test_typeParameterReferencedByStatic_field() { |
| 3377 Source source = addSource(r''' | 3419 Source source = addSource(r''' |
| 3378 class A<K> { | 3420 class A<K> { |
| 3379 static K k; | 3421 static K k; |
| 3380 }'''); | 3422 }'''); |
| 3381 computeLibrarySourceErrors(source); | 3423 computeLibrarySourceErrors(source); |
| 3382 assertErrors( | 3424 assertErrors( |
| 3383 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 3425 source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); |
| 3384 verify([source]); | 3426 verify([source]); |
| 3385 } | 3427 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3681 | 3723 |
| 3682 void test_voidReturnForGetter() { | 3724 void test_voidReturnForGetter() { |
| 3683 Source source = addSource(r''' | 3725 Source source = addSource(r''' |
| 3684 class S { | 3726 class S { |
| 3685 void get value {} | 3727 void get value {} |
| 3686 }'''); | 3728 }'''); |
| 3687 computeLibrarySourceErrors(source); | 3729 computeLibrarySourceErrors(source); |
| 3688 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3730 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
| 3689 } | 3731 } |
| 3690 } | 3732 } |
| OLD | NEW |