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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 19669010: Fix generic mixins (issue 11803). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 25135)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -1257,9 +1257,9 @@
// Copy the type parameters of the super and mixin classes to the
-// mixin application class. Change type arguments of super type to
-// refer to the respective type parameters of the mixin application
-// class.
+// mixin application class. Change type arguments of super type and of
+// interfaces to refer to the respective type parameters of the mixin
+// application class.
void ClassFinalizer::CloneTypeParameters(const Class& mixapp_class) {
ASSERT(mixapp_class.NumTypeParameters() == 0);
@@ -1318,6 +1318,7 @@
// TODO(hausner): May need to handle BoundedType here.
ASSERT(super_type.IsType());
Type::Cast(super_type).set_arguments(super_type_args);
+ ASSERT(!super_type.IsFinalized());
}
// Second, clone the type parameters of the mixin class.
@@ -1328,6 +1329,8 @@
if (num_mixin_parameters > 0) {
const TypeArguments& mixin_params =
TypeArguments::Handle(mixin_class.type_parameters());
+ const TypeArguments& interface_type_args = TypeArguments::Handle(
+ TypeArguments::New(num_mixin_parameters));
for (int i = 0; i < num_mixin_parameters; i++) {
param ^= mixin_params.TypeAt(i);
param_name = param.name();
@@ -1347,8 +1350,21 @@
param_bound,
param.token_pos());
cloned_type_params.SetTypeAt(cloned_index, cloned_param);
+ interface_type_args.SetTypeAt(i, cloned_param);
cloned_index++;
}
+
+ // Lastly, change the type arguments of the single interface type to
+ // refer to the cloned type parameters of the mixin application class.
+ Array& interface_types = Array::Handle(mixapp_class.interfaces());
+ ASSERT(interface_types.Length() == 1);
+ AbstractType& interface_type = AbstractType::Handle();
+ interface_type ^= interface_types.At(0);
+ ASSERT(interface_type.IsResolved());
+ // TODO(hausner): May need to handle BoundedType here.
+ ASSERT(interface_type.IsType());
+ Type::Cast(interface_type).set_arguments(interface_type_args);
+ ASSERT(!interface_type.IsFinalized());
}
mixapp_class.set_type_parameters(cloned_type_params);
}
@@ -1362,7 +1378,7 @@
if (FLAG_trace_class_finalization) {
OS::Print("Applying mixin type '%s' to '%s' at pos %"Pd"\n",
- String::Handle(mixin_cls.Name()).ToCString(),
+ String::Handle(mixin_type.Name()).ToCString(),
cls.ToCString(),
cls.token_pos());
}
@@ -1383,7 +1399,8 @@
CloneTypeParameters(cls);
if (FLAG_trace_class_finalization) {
- OS::Print("done mixin type appl %s %s extending '%s'\n",
+ OS::Print("Done applying mixin type '%s' to class %s %s extending '%s'\n",
+ String::Handle(mixin_type.Name()).ToCString(),
String::Handle(cls.Name()).ToCString(),
TypeArguments::Handle(cls.type_parameters()).ToCString(),
AbstractType::Handle(cls.super_type()).ToCString());
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698