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

Unified Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 640813004: Handle non-factory redirects in constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index 2c00d92c9ba5cca3a86a755a4d4859816cc4be36..fa82b571354fa9a9dfddd115497662bb5c6f0982 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -791,6 +791,15 @@ class ConstantValueComputer {
superName = name.name;
}
superArguments = superConstructorInvocation.argumentList.arguments;
+ } else if (initializer is RedirectingConstructorInvocation) {
+ // This is a redirecting constructor, so just evaluate the constructor
+ // it redirects to.
+ ConstructorElement constructor = initializer.staticElement;
+ if (constructor != null && constructor.isConst) {
+ return _evaluateConstructorCall(
+ node, initializer.argumentList.arguments, constructor,
+ initializerVisitor, errorReporter);
+ }
}
}
// Evaluate explicit or implicit call to super().
@@ -915,6 +924,15 @@ class ConstantValueComputer_InitializerCloner extends AstCloner {
invocation.staticElement = node.staticElement;
return invocation;
}
+
+ @override
+ RedirectingConstructorInvocation visitRedirectingConstructorInvocation(
+ RedirectingConstructorInvocation node) {
+ RedirectingConstructorInvocation invocation =
+ super.visitRedirectingConstructorInvocation(node);
+ invocation.staticElement = node.staticElement;
+ return invocation;
+ }
}
/**
@@ -4458,6 +4476,19 @@ class ReferenceFinder extends RecursiveAstVisitor<Object> {
}
return null;
}
+
+ @override
+ Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
+ super.visitRedirectingConstructorInvocation(node);
+ ConstructorElement target = node.staticElement;
+ if (target != null && target.isConst) {
+ ConstructorDeclaration targetDeclaration = _constructorDeclarationMap[target];
+ if (targetDeclaration != null) {
+ _referenceGraph.addEdge(_source, targetDeclaration);
+ }
+ }
+ return null;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698