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 3356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() { | 3376 void test_typeAnnotationGenericFunctionParameter_localFunction() { |
3377 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); | |
3378 Source source = addSource(r''' | 3377 Source source = addSource(r''' |
3379 class A { | 3378 class A { |
3380 void method() { | 3379 void method() { |
3381 T local<T>(Object t) { | 3380 T local<T>(Object t) { |
3382 return (t is T) ? t : null; | 3381 return (t is T) ? t : null; |
3383 } | 3382 } |
3384 } | 3383 } |
3385 }'''); | 3384 }'''); |
3386 computeLibrarySourceErrors(source); | 3385 computeLibrarySourceErrors(source); |
3387 assertErrors( | 3386 assertErrors( |
3388 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); | 3387 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); |
3389 verify([source]); | 3388 verify([source]); |
3390 } | 3389 } |
3391 | 3390 |
3392 void test_typeAnnotationGenericFunctionParameter_method() { | 3391 void test_typeAnnotationGenericFunctionParameter_method() { |
3393 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); | |
3394 Source source = addSource(r''' | 3392 Source source = addSource(r''' |
3395 class A { | 3393 class A { |
3396 T method<T>(Object t) { | 3394 T method<T>(Object t) { |
3397 return (t is T) ? t : null; | 3395 return (t is T) ? t : null; |
3398 } | 3396 } |
3399 }'''); | 3397 }'''); |
3400 computeLibrarySourceErrors(source); | 3398 computeLibrarySourceErrors(source); |
3401 assertErrors( | 3399 assertErrors( |
3402 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); | 3400 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); |
3403 verify([source]); | 3401 verify([source]); |
3404 } | 3402 } |
3405 | 3403 |
3406 void test_typeAnnotationGenericFunctionParameter_topLevelFunction() { | 3404 void test_typeAnnotationGenericFunctionParameter_topLevelFunction() { |
3407 resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true); | |
3408 Source source = addSource(r''' | 3405 Source source = addSource(r''' |
3409 T function<T>(Object t) { | 3406 T function<T>(Object t) { |
3410 return (t is T) ? t : null; | 3407 return (t is T) ? t : null; |
3411 }'''); | 3408 }'''); |
3412 computeLibrarySourceErrors(source); | 3409 computeLibrarySourceErrors(source); |
3413 assertErrors( | 3410 assertErrors( |
3414 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); | 3411 source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]); |
3415 verify([source]); | 3412 verify([source]); |
3416 } | 3413 } |
3417 | 3414 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3723 | 3720 |
3724 void test_voidReturnForGetter() { | 3721 void test_voidReturnForGetter() { |
3725 Source source = addSource(r''' | 3722 Source source = addSource(r''' |
3726 class S { | 3723 class S { |
3727 void get value {} | 3724 void get value {} |
3728 }'''); | 3725 }'''); |
3729 computeLibrarySourceErrors(source); | 3726 computeLibrarySourceErrors(source); |
3730 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3727 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
3731 } | 3728 } |
3732 } | 3729 } |
OLD | NEW |