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

Unified Diff: pkg/analyzer_experimental/lib/src/generated/resolver.dart

Issue 18325018: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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
Index: pkg/analyzer_experimental/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer_experimental/lib/src/generated/resolver.dart b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
index 09eed5620488cf331814e0e3a4a63f7e3520be8a..0a19e83d46c29a040de8f1aab56ced84e5e2ec2e 100644
--- a/pkg/analyzer_experimental/lib/src/generated/resolver.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
@@ -10802,6 +10802,12 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
bool _isInCatchClause = false;
/**
+ * This is set to `true` iff the visitor is currently visiting a static variable
+ * declaration.
+ */
+ bool _isInStaticVariableDeclaration = false;
+
+ /**
* This is set to `true` iff the visitor is currently visiting an instance variable
* declaration.
*/
@@ -10820,7 +10826,9 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
bool _isInConstructorInitializer = false;
/**
- * This is set to `true` iff the visitor is currently visiting a static method.
+ * This is set to `true` iff the visitor is currently visiting a static method. By "method"
+ * here getter, setter and operator declarations are also implied since they are all represented
+ * with a [MethodDeclaration] in the AST structure.
*/
bool _isInStaticMethod = false;
@@ -10891,6 +10899,11 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
_strictMode = currentLibrary.context.analysisOptions.strictMode;
_isEnclosingConstructorConst = false;
_isInCatchClause = false;
+ _isInStaticVariableDeclaration = false;
+ _isInInstanceVariableDeclaration = false;
+ _isInInstanceVariableInitializer = false;
+ _isInConstructorInitializer = false;
+ _isInStaticMethod = false;
_dynamicType = typeProvider.dynamicType;
_DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [typeProvider.numType, typeProvider.intType, typeProvider.doubleType, typeProvider.boolType, typeProvider.stringType];
}
@@ -11036,10 +11049,12 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
_errorReporter.reportError4(CompileTimeErrorCode.CONST_INSTANCE_FIELD, variables.keyword, []);
}
}
- _isInInstanceVariableDeclaration = !node.isStatic;
+ _isInStaticVariableDeclaration = node.isStatic;
+ _isInInstanceVariableDeclaration = !_isInStaticVariableDeclaration;
try {
return super.visitFieldDeclaration(node);
} finally {
+ _isInStaticVariableDeclaration = false;
_isInInstanceVariableDeclaration = false;
}
}
@@ -11264,6 +11279,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
}
Object visitTypeName(TypeName node) {
checkForTypeArgumentNotMatchingBounds(node);
+ checkForTypeParameterReferencedByStatic(node);
return super.visitTypeName(node);
}
Object visitTypeParameter(TypeParameter node) {
@@ -13842,6 +13858,25 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
}
/**
+ * This checks that if the passed type name is a type parameter being used to define a static
+ * member.
+ *
+ * @param node the type name to evaluate
+ * @return `true` if and only if an error code is generated on the passed node
+ * @see StaticWarningCode#TYPE_PARAMETER_REFERENCED_BY_STATIC
+ */
+ bool checkForTypeParameterReferencedByStatic(TypeName node) {
+ if (_isInStaticMethod || _isInStaticVariableDeclaration) {
+ Type2 type = node.type;
+ if (type is TypeVariableType) {
+ _errorReporter.reportError2(StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC, node, []);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* This checks that if the passed generative constructor has neither an explicit super constructor
* invocation nor a redirecting constructor invocation, that the superclass has a default
* generative constructor.
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/parser.dart ('k') | pkg/analyzer_experimental/test/generated/ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698