| 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 ab40ce800bce046395c54340d1d231b9bae1bc71..f8a1374224b7c8b4f6d80f2fc2623d7a07cb17c2 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
|
| @@ -457,6 +457,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| try {
|
| enclosingClass = node.getElement();
|
| checkForRecursiveInterfaceInheritance(node.getElement(), new ArrayList<ClassElement>());
|
| + checkForTypeAliasCannotReferenceItself_mixin(node);
|
| } finally {
|
| enclosingClass = outerClassElement;
|
| }
|
| @@ -608,7 +609,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| node.getName(),
|
| CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME);
|
| checkForDefaultValueInFunctionTypeAlias(node);
|
| - checkForTypeAliasCannotReferenceItself(node);
|
| + checkForTypeAliasCannotReferenceItself_function(node);
|
| return super.visitFunctionTypeAlias(node);
|
| }
|
|
|
| @@ -4229,7 +4230,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| * @return {@code true} if and only if an error code is generated on the passed node
|
| * @see CompileTimeErrorCode#TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
|
| */
|
| - private boolean checkForTypeAliasCannotReferenceItself(FunctionTypeAlias node) {
|
| + private boolean checkForTypeAliasCannotReferenceItself_function(FunctionTypeAlias node) {
|
| FunctionTypeAliasElement element = node.getElement();
|
| if (!hasFunctionTypeAliasSelfReference(element)) {
|
| return false;
|
| @@ -4239,6 +4240,21 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * This verifies that the given class type alias does not reference itself.
|
| + *
|
| + * @return {@code true} if and only if an error code is generated on the passed node
|
| + * @see CompileTimeErrorCode#TYPE_ALIAS_CANNOT_REFERENCE_ITSELF
|
| + */
|
| + private boolean checkForTypeAliasCannotReferenceItself_mixin(ClassTypeAlias node) {
|
| + ClassElement element = node.getElement();
|
| + if (!hasClassTypeAliasSelfReference(element, new HashSet<ClassElement>())) {
|
| + return false;
|
| + }
|
| + errorReporter.reportError(CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, node);
|
| + return true;
|
| + }
|
| +
|
| + /**
|
| * This verifies that the type arguments in the passed type name are all within their bounds.
|
| *
|
| * @param node the {@link TypeName} to evaluate
|
| @@ -4585,6 +4601,28 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * @return <code>true</code> if given {@link ClassElement} has direct or indirect reference to
|
| + * itself using only other typedef {@link ClassElement}s.
|
| + */
|
| + private boolean hasClassTypeAliasSelfReference(ClassElement element,
|
| + HashSet<ClassElement> seenMixins) {
|
| + if (seenMixins.contains(element)) {
|
| + return true;
|
| + }
|
| + seenMixins.add(element);
|
| + for (InterfaceType mixin : element.getMixins()) {
|
| + ClassElement mixinElement = mixin.getElement();
|
| + if (!mixinElement.isTypedef()) {
|
| + continue;
|
| + }
|
| + if (hasClassTypeAliasSelfReference(mixinElement, seenMixins)) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| * Checks if "target" is referenced by "current".
|
| */
|
| private boolean hasFunctionTypeAliasReference(Set<FunctionTypeAliasElement> visited,
|
|
|