Chromium Code Reviews| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
| index f458f0b53e35756b78dd21fd3f6b89f74ffa331d..e3ad8d80303470dafdb5dbeefc4b43dc52b6c73d 100644 |
| --- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java |
| @@ -50,6 +50,7 @@ import com.google.dart.engine.ast.FunctionBody; |
| import com.google.dart.engine.ast.FunctionDeclaration; |
| import com.google.dart.engine.ast.FunctionExpression; |
| import com.google.dart.engine.ast.FunctionTypeAlias; |
| +import com.google.dart.engine.ast.FunctionTypedFormalParameter; |
| import com.google.dart.engine.ast.Identifier; |
| import com.google.dart.engine.ast.IfStatement; |
| import com.google.dart.engine.ast.ImplementsClause; |
| @@ -274,6 +275,12 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> { |
| private boolean isInConstructorInitializer; |
| /** |
| + * This is set to {@code true} iff the visitor is currently visiting a |
| + * {@link FunctionTypedFormalParameter}. |
| + */ |
| + private boolean isInFunctionTypedFormalParameter; |
| + |
| + /** |
| * This is set to {@code 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 {@link MethodDeclaration} in the AST structure. |
| @@ -527,6 +534,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> { |
| @Override |
| public Void visitDefaultFormalParameter(DefaultFormalParameter node) { |
| checkForInvalidAssignment(node.getIdentifier(), node.getDefaultValue()); |
| + checkForDefaultValueInFunctionTypedParameter(node); |
| return super.visitDefaultFormalParameter(node); |
| } |
| @@ -639,6 +647,17 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> { |
| } |
| @Override |
| + public Void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| + boolean old = isInFunctionTypedFormalParameter; |
| + isInFunctionTypedFormalParameter = true; |
| + try { |
| + return super.visitFunctionTypedFormalParameter(node); |
| + } finally { |
| + isInFunctionTypedFormalParameter = old; |
| + } |
| + } |
| + |
| + @Override |
| public Void visitIfStatement(IfStatement node) { |
| checkForNonBoolCondition(node.getCondition()); |
| return super.visitIfStatement(node); |
| @@ -2475,6 +2494,28 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> { |
| } |
| /** |
| + * This verifies that the given default formal parameter is not part of an function typed |
|
Brian Wilkerson
2013/08/12 19:50:28
nit: "an" --> "a"
|
| + * parameter. TODO(scheglov) |
|
Brian Wilkerson
2013/08/12 19:50:28
Remove the TODO?
|
| + * |
| + * @param node the default formal parameter to evaluate |
| + * @return {@code true} if and only if an error code is generated on the passed node |
| + * @see CompileTimeErrorCode#DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER |
| + */ |
| + private boolean checkForDefaultValueInFunctionTypedParameter(DefaultFormalParameter node) { |
| + // OK, not in a function typed parameter. |
| + if (!isInFunctionTypedFormalParameter) { |
| + return false; |
| + } |
| + // OK, no default value. |
| + if (node.getDefaultValue() == null) { |
| + return false; |
| + } |
| + // Report problem. |
| + errorReporter.reportError(CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER, node); |
| + return true; |
| + } |
| + |
| + /** |
| * This verifies that the enclosing class does not have an instance member with the given name of |
| * the static member. |
| * |