| 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 48c94210700c96f69ebe21d6ca5175997e9b451b..42022859a8852a912d452e84aeee8ca5b4cc9de5 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
|
| @@ -412,6 +412,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| checkForRecursiveFactoryRedirect(node);
|
| checkForRedirectToInvalidFunction(node);
|
| checkForUndefinedConstructorInInitializerImplicit(node);
|
| + checkForRedirectToNonConstConstructor(node);
|
| return super.visitConstructorDeclaration(node);
|
| } finally {
|
| isEnclosingConstructorConst = false;
|
| @@ -3211,6 +3212,45 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * This checks if the passed constructor declaration has redirected constructor and references
|
| + * itself directly or indirectly. TODO(scheglov)
|
| + *
|
| + * @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#REDIRECT_TO_NON_CONST_CONSTRUCTOR
|
| + */
|
| + private boolean checkForRedirectToNonConstConstructor(ConstructorDeclaration node) {
|
| + // prepare redirected constructor
|
| + ConstructorName redirectedConstructorNode = node.getRedirectedConstructor();
|
| + if (redirectedConstructorNode == null) {
|
| + return false;
|
| + }
|
| + // prepare element
|
| + ConstructorElement element = node.getElement();
|
| + if (element == null) {
|
| + return false;
|
| + }
|
| + // OK, it is not 'const'
|
| + if (!element.isConst()) {
|
| + return false;
|
| + }
|
| + // prepare redirected constructor
|
| + ConstructorElement redirectedConstructor = element.getRedirectedConstructor();
|
| + if (redirectedConstructor == null) {
|
| + return false;
|
| + }
|
| + // OK, it is also 'const'
|
| + if (redirectedConstructor.isConst()) {
|
| + return false;
|
| + }
|
| + // report error
|
| + errorReporter.reportError(
|
| + CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR,
|
| + redirectedConstructorNode);
|
| + return true;
|
| + }
|
| +
|
| + /**
|
| * This checks if the passed identifier is banned because it is part of the variable declaration
|
| * with the same name.
|
| *
|
|
|