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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java

Issue 10553037: Issue 963. Check default values for parameters of local functions. Support for string interpolation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
index 1ba0d4653a761508dc9ec3bf52e349262a689bd0..a3f107afbfb5b9b5731e6ffc057e5ca914baecb7 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -13,6 +13,7 @@ import com.google.dart.compiler.InternalCompilerException;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartArrayLiteral;
import com.google.dart.compiler.ast.DartBinaryExpression;
+import com.google.dart.compiler.ast.DartBlock;
import com.google.dart.compiler.ast.DartBooleanLiteral;
import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartDeclaration;
@@ -49,7 +50,6 @@ import com.google.dart.compiler.ast.Modifiers;
import com.google.dart.compiler.common.HasSourceInfo;
import com.google.dart.compiler.type.Type;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -479,7 +479,11 @@ public class CompileTimeConstantAnalyzer {
@Override
public Void visitStringInterpolation(DartStringInterpolation x) {
- expectedConstant(x);
+ x.visitChildren(this);
+ for (DartExpression expression : x.getExpressions()) {
+ Type expressionType = getMostSpecificType(expression);
+ checkNumberBooleanOrStringType(expression, expressionType);
+ }
return null;
}
@@ -566,11 +570,15 @@ public class CompileTimeConstantAnalyzer {
@Override
public Void visitMethodDefinition(DartMethodDefinition node) {
DartFunction functionNode = node.getFunction();
- List<DartParameter> parameters = functionNode.getParameters();
- for (DartParameter parameter : parameters) {
- // Then resolve the default values.
+ // check parameters default value
+ for (DartParameter parameter : functionNode.getParameters()) {
checkConstantExpression(parameter.getDefaultExpr());
}
+ // continue into body (to check local functions)
+ DartBlock body = node.getFunction().getBody();
+ if (body != null) {
+ super.visitBlock(body);
+ }
return null;
}

Powered by Google App Engine
This is Rietveld 408576698