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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.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/error/codes.dart ('k') | pkg/analyzer/test/generated/static_warning_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 27bb23d0d95d332239457e2bb38b2b70219fcced..2a71ac62d48573331c0f79db9bd36cb9fd2d3459 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -924,6 +924,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitIsExpression(IsExpression node) {
_checkForTypeAnnotationDeferredClass(node.type);
+ _checkForTypeAnnotationGenericFunctionParameter(node.type);
return super.visitIsExpression(node);
}
@@ -2610,8 +2611,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
// terminated with 'throw' expression
if (statement is ExpressionStatement) {
Expression expression = statement.expression;
- if (expression is ThrowExpression ||
- expression is RethrowExpression) {
+ if (expression is ThrowExpression || expression is RethrowExpression) {
return;
}
}
@@ -5690,6 +5690,29 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
/**
+ * Verify that the given type [name] is not a type parameter in a generic
+ * method.
+ *
+ * See [StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER].
+ */
+ void _checkForTypeAnnotationGenericFunctionParameter(TypeName typeName) {
+ if (typeName == null) {
+ return;
+ }
+ Identifier name = typeName.name;
+ if (name is SimpleIdentifier) {
+ Element element = name.staticElement;
+ if (element is TypeParameterElement &&
+ element.enclosingElement is ExecutableElement) {
+ _errorReporter.reportErrorForNode(
+ StaticWarningCode.TYPE_ANNOTATION_GENERIC_FUNCTION_PARAMETER,
+ name,
+ [name.name]);
+ }
+ }
+ }
+
+ /**
* Verify that the type arguments in the given [typeName] are all within
* their bounds.
*
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.dart ('k') | pkg/analyzer/test/generated/static_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698