| 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 68e94b7e18af32d73abd37f3d8c81b74b843e3cd..37c3a514d3801dcf2b160d364d573a700351a8cf 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
|
| @@ -342,6 +342,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| checkForConflictingConstructorNameAndMember(node);
|
| checkForAllFinalInitializedErrorCodes(node);
|
| checkForMultipleSuperInitializers(node);
|
| + checkForRecursiveConstructorRedirect(node);
|
| checkForRecursiveFactoryRedirect(node);
|
| checkForRedirectToInvalidFunction(node);
|
| return super.visitConstructorDeclaration(node);
|
| @@ -2308,6 +2309,36 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * This checks if the passed constructor declaration is the redirecting generative constructor and
|
| + * references itself directly or indirectly.
|
| + *
|
| + * @param node the constructor declaration to evaluate
|
| + * @return {@code true} if and only if an error code is generated on the passed node
|
| + * @see CompileTimeErrorCode#RECURSIVE_CONSTRUCTOR_REDIRECT
|
| + */
|
| + private boolean checkForRecursiveConstructorRedirect(ConstructorDeclaration node) {
|
| + // we check generative constructor here
|
| + if (node.getFactoryKeyword() != null) {
|
| + return false;
|
| + }
|
| + // try to find redirecting constructor invocation and analyzer it for recursion
|
| + for (ConstructorInitializer initializer : node.getInitializers()) {
|
| + if (initializer instanceof RedirectingConstructorInvocation) {
|
| + // OK if no cycle
|
| + ConstructorElement element = node.getElement();
|
| + if (!hasRedirectingFactoryConstructorCycle(element)) {
|
| + return false;
|
| + }
|
| + // report error
|
| + errorReporter.reportError(CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, initializer);
|
| + return true;
|
| + }
|
| + }
|
| + // OK, no redirecting constructor invocation
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| * This checks if the passed constructor declaration has redirected constructor with compatible
|
| * function type.
|
| *
|
|
|