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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 12018014: Start allowing mixin application extensions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Extend test cases. 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: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 2733dde49c70f573fcea0ae685834526d10da7ff..3398dfdfe13cc646b4e57e6bb14332fa774ad2c4 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -2737,8 +2737,24 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
// resolve this class again.
resolveTypeVariableBounds(node.typeParameters);
- // Resolve super type and deal with the Object class nicely.
- element.supertype = resolveSupertype(element, node.superclass);
+ // Setup the supertype for the element.
+ assert(element.supertype == null);
+ if (node.superclass != null) {
+ MixinApplication superMixin = node.superclass.asMixinApplication();
+ if (superMixin != null) {
+ DartType supertype = resolveSupertype(element, superMixin.superclass);
+ Link<Node> link = superMixin.mixins.nodes;
+ while (!link.isEmpty) {
+ supertype = applyMixin(supertype, visit(link.head));
+ link = link.tail;
+ }
+ element.supertype = supertype;
+ } else {
+ element.supertype = resolveSupertype(element, node.superclass);
+ }
+ }
+
+ // If the super type isn't specified, we make it Object.
final objectElement = compiler.objectClass;
if (!identical(element, objectElement) && element.supertype == null) {
if (objectElement == null) {
@@ -2817,16 +2833,11 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
DartType applyMixin(DartType supertype, DartType mixinType) {
String superName = supertype.name.slowToString();
String mixinName = mixinType.name.slowToString();
- // TODO(kasperl): This is a little bit weird. Maybe we should
- // restructure the parsed nodes for mixin applications to better
- // match the nesting implied by the list of mixins so that each
- // mixin application element could get it's own proper node.
- MixinApplication fakeTree = element.parseNode(compiler);
ClassElement mixinApplication = new MixinApplicationElementX(
new SourceString("${superName}_${mixinName}"),
element.getCompilationUnit(),
compiler.getNextFreeClassId(),
- fakeTree);
+ element.parseNode(compiler));
doApplyMixinTo(mixinApplication, supertype, mixinType);
mixinApplication.resolutionState = STATE_DONE;
mixinApplication.supertypeLoadState = STATE_DONE;
@@ -2846,7 +2857,7 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
assert(mixinApplication.interfaces == null);
mixinApplication.interfaces = interfaces;
- assert(element.mixin == null);
+ assert(mixinApplication.mixin == null);
mixinApplication.mixin = mixinType.element;
mixinApplication.mixin.ensureResolved(compiler);
mixinApplication.addDefaultConstructorIfNeeded(compiler);
@@ -2905,11 +2916,8 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
}
DartType resolveSupertype(ClassElement cls, TypeAnnotation superclass) {
- DartType supertype;
- if (superclass != null) {
- supertype = typeResolver.resolveTypeAnnotation(
- superclass, scope, cls, onFailure: error);
- }
+ DartType supertype = typeResolver.resolveTypeAnnotation(
+ superclass, scope, cls, onFailure: error);
if (supertype != null) {
if (identical(supertype.kind, TypeKind.MALFORMED_TYPE)) {
// Error has already been reported.

Powered by Google App Engine
This is Rietveld 408576698