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

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

Issue 88153003: Add synthetic type variables to unnamed mixin applications. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove unneeded handling of unnamed mixin applications. Created 7 years, 1 month 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 598dde2810cd88ad7795f4bbed9397dca5a73614..d455ab744b451c5785d160a8ca55494c24922bd8 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -3824,8 +3824,7 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
DartType supertype = resolveSupertype(element, superMixin.superclass);
Link<Node> link = superMixin.mixins.nodes;
while (!link.isEmpty) {
- supertype = applyMixin(
- supertype, checkMixinType(link.head), link.head);
+ supertype = applyMixin(supertype, checkMixinType(link.head), link.head);
karlklose 2013/11/28 15:04:16 Long line.
Johnni Winther 2013/12/03 15:57:38 Done.
link = link.tail;
}
element.supertype = supertype;
@@ -3921,16 +3920,45 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
DartType applyMixin(DartType supertype, DartType mixinType, Node node) {
String superName = supertype.name;
String mixinName = mixinType.name;
- ClassElement mixinApplication = new MixinApplicationElementX(
+ MixinApplicationElementX mixinApplication = new MixinApplicationElementX(
karlklose 2013/11/28 15:04:16 Do you need the implementation (X) class here?
Johnni Winther 2013/12/03 15:57:38 Needed to call computeThisAndRawType.
"${superName}+${mixinName}",
element.getCompilationUnit(),
compiler.getNextFreeClassId(),
node,
Modifiers.EMPTY); // TODO(kasperl): Should this be abstract?
+ // Create synthetic type variables for the mixin application.
+ LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>();
+ element.typeVariables.forEach((TypeVariableType type) {
+ TypeVariableElementX typeVariableElement = new TypeVariableElementX(
+ type.name, mixinApplication, type.element.parseNode(compiler));
+ TypeVariableType typeVariable = new TypeVariableType(typeVariableElement);
+ typeVariablesBuilder.addLast(typeVariable);
+ });
+ Link<DartType> typeVariables = typeVariablesBuilder.toLink();
+ // Setup bounds on the synthetic type variables.
+ Link<DartType> link = typeVariables;
+ element.typeVariables.forEach((TypeVariableType type) {
+ TypeVariableType typeVariable = link.head;
+ TypeVariableElement typeVariableElement = typeVariable.element;
+ typeVariableElement.type = typeVariable;
+ typeVariableElement.bound =
+ type.element.bound.subst(typeVariables, element.typeVariables);
+ link = link.tail;
+ });
+ // Setup this and raw type for the mixin application.
+ mixinApplication.computeThisAndRawType(compiler, typeVariables);
+ // Substitute in synthetic type variables in super and mixin types.
+ supertype = supertype.subst(typeVariables, element.typeVariables);
+ mixinType = mixinType.subst(typeVariables, element.typeVariables);
+
doApplyMixinTo(mixinApplication, supertype, mixinType);
mixinApplication.resolutionState = STATE_DONE;
mixinApplication.supertypeLoadState = STATE_DONE;
- return mixinApplication.computeType(compiler);
+ // Replace the synthetic type variables by the original type variables in
+ // the returning type (which should be the type actually extended).
karlklose 2013/11/28 15:04:16 'returning type' -> 'returned type'?
Johnni Winther 2013/12/03 15:57:38 Done.
+ InterfaceType mixinThisType = mixinApplication.computeType(compiler);
+ return mixinThisType.subst(element.typeVariables,
+ mixinThisType.typeArguments);
}
bool isDefaultConstructor(FunctionElement constructor) {
@@ -4127,7 +4155,7 @@ class ClassResolverVisitor extends TypeDefinitionVisitor {
cls.allSupertypesAndSelf =
new OrderedTypeSet.singleton(cls.computeType(compiler));
}
- }
+ }
/**
* Adds [type] and all supertypes of [type] to [allSupertypes] while

Powered by Google App Engine
This is Rietveld 408576698