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

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

Issue 1115993005: Clone AST nodes of default formal parameters prior to constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 13921b7f44803e5a8da3f92ea8fd5f1d60d15f33..7e3842643a6c2b010b15db96b6227b5ba91ba4f9 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -1162,7 +1162,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) ||
identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) ||
identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM) ||
- identical(dataErrorCode, CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT) ||
+ identical(dataErrorCode,
+ CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT) ||
identical(dataErrorCode,
CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH) ||
identical(dataErrorCode,
@@ -10916,6 +10917,22 @@ class ResolverVisitor extends ScopedVisitor {
}
@override
+ Object visitDefaultFormalParameter(DefaultFormalParameter node) {
+ super.visitDefaultFormalParameter(node);
+ FormalParameterList parent = node.parent;
+ AstNode grandparent = parent.parent;
+ if (grandparent is ConstructorDeclaration &&
+ grandparent.constKeyword != null) {
+ // For const constructors, we need to clone the ASTs for default formal
+ // parameters, so that we can use them during constant evaluation.
+ ParameterElement element = node.element;
+ (element as ConstVariableElement).constantInitializer =
+ new ConstantAstCloner().cloneNode(node.defaultValue);
+ }
+ return null;
+ }
+
+ @override
Object visitDoStatement(DoStatement node) {
_overrideManager.enterScope();
try {
« pkg/analyzer/lib/src/generated/element.dart ('K') | « pkg/analyzer/lib/src/generated/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698