Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 12039054: Issue 8059. Disallow mixing in classes that use 'super' from any member. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index 7b115dd3796bed81aa0cb768fc8019406db8a75a..f85ccd538e2eb04a2a9491ffdf567437bc38777e 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -373,6 +373,7 @@ public class Resolver {
onError(errorTarget, ResolverErrorCode.CYCLIC_CLASS, e.getElement().getName());
}
checkMixinNoConstructors(cls.getMixins());
+ checkMixinNoSuperInvocations(cls.getMixins());
return classElement;
}
@@ -488,8 +489,9 @@ public class Resolver {
}
}
- // check that mixin types don't have constructors
+ // check mixins
checkMixinNoConstructors(cls.getMixins());
+ checkMixinNoSuperInvocations(cls.getMixins());
context = previousContext;
currentHolder = previousHolder;
@@ -513,6 +515,24 @@ public class Resolver {
}
}
}
+
+ /**
+ * Checks that the types of the given mixin type node don't have super invocations.
+ */
+ private void checkMixinNoSuperInvocations(List<DartTypeNode> mixins) {
+ for (DartTypeNode mixNode : mixins) {
+ if (mixNode.getType() instanceof InterfaceType) {
+ InterfaceType mixType = (InterfaceType) mixNode.getType();
+ if (mixType.getElement() instanceof ClassElement) {
+ ClassElement mixElement = (ClassElement) mixType.getElement();
+ if (mixElement.hasSuperInvocation()) {
+ topLevelContext.onError(mixNode, ResolverErrorCode.CANNOT_MIXIN_CLASS_WITH_SUPER);
+ break;
+ }
+ }
+ }
+ }
+ }
private void constVerifyMembers(Iterable<? extends Element> members, ClassElement originalClass,
ClassElement currentClass) {

Powered by Google App Engine
This is Rietveld 408576698