| 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 430642bef06dd1f865d974b857994d6baa337cce..c7e2be7dfa9581fd50d6951836bcf51c08fb19f3 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
|
| @@ -47,6 +47,7 @@ import com.google.dart.engine.ast.FieldDeclaration;
|
| import com.google.dart.engine.ast.FieldFormalParameter;
|
| import com.google.dart.engine.ast.FormalParameter;
|
| import com.google.dart.engine.ast.FormalParameterList;
|
| +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;
|
| @@ -475,6 +476,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| checkForAllRedirectConstructorErrorCodes(node);
|
| checkForUndefinedConstructorInInitializerImplicit(node);
|
| checkForRedirectToNonConstConstructor(node);
|
| + checkForReturnInGenerativeConstructor(node);
|
| return super.visitConstructorDeclaration(node);
|
| } finally {
|
| isEnclosingConstructorConst = false;
|
| @@ -3906,6 +3908,29 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * This checks that if the the given constructor declaration is generative, then it does not have
|
| + * an expression function body.
|
| + *
|
| + * @param node the constructor to evaluate
|
| + * @return {@code true} if and only if an error code is generated on the passed node
|
| + * @see CompileTimeErrorCode#RETURN_IN_GENERATIVE_CONSTRUCTOR
|
| + */
|
| + private boolean checkForReturnInGenerativeConstructor(ConstructorDeclaration node) {
|
| + // ignore factory
|
| + if (node.getFactoryKeyword() != null) {
|
| + return false;
|
| + }
|
| + // block body (with possible return statement) is checked elsewhere
|
| + FunctionBody body = node.getBody();
|
| + if (!(body instanceof ExpressionFunctionBody)) {
|
| + return false;
|
| + }
|
| + // report error
|
| + errorReporter.reportError(CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR, body);
|
| + return true;
|
| + }
|
| +
|
| + /**
|
| * This checks that a type mis-match between the return type and the expressed return type by the
|
| * enclosing method or function.
|
| * <p>
|
|
|