Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: pkg/analyzer/test/generated/static_warning_code_test.dart

Issue 2479293004: Add an error when a type parameter from a generic function is used in an is test (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/static_warning_code_test.dart
diff --git a/pkg/analyzer/test/generated/static_warning_code_test.dart b/pkg/analyzer/test/generated/static_warning_code_test.dart
index 0a7087d7fdc5ebab5b7bf75e32b4b8bad2d21052..ae8bdca538cf019fdc036ac51640a60b3b655952 100644
--- a/pkg/analyzer/test/generated/static_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_warning_code_test.dart
@@ -3373,6 +3373,48 @@ a.A v;'''
]);
}
+ void test_typeAnnotationGenericFunctionParameter_localFunction() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
+ Source source = addSource(r'''
+class A {
+ void method() {
+ T local<T>(Object t) {
+ return (t is T) ? t : null;
+ }
+ }
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(
+ source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
+ verify([source]);
+ }
+
+ void test_typeAnnotationGenericFunctionParameter_method() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
+ Source source = addSource(r'''
+class A {
+ T method<T>(Object t) {
+ return (t is T) ? t : null;
+ }
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(
+ source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
+ verify([source]);
+ }
+
+ void test_typeAnnotationGenericFunctionParameter_topLevelFunction() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableGenericMethods = true);
+ Source source = addSource(r'''
+T function<T>(Object t) {
+ return (t is T) ? t : null;
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(
+ source, [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER]);
+ verify([source]);
+ }
+
void test_typeParameterReferencedByStatic_field() {
Source source = addSource(r'''
class A<K> {
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698