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

Unified Diff: runtime/vm/object.cc

Issue 1950133002: Fix cloning of generic function types when applying mixin members to mixin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index f466a1007ce04a82191c854bf66b399735f39d3e..9b48ab326bde4cdc7d308cde147332f495179ea6 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -16791,9 +16791,29 @@ RawAbstractType* Type::CloneUninstantiated(const Class& new_owner,
const LanguageError& bound_error = LanguageError::Handle(zone, error());
clone.set_error(bound_error);
}
+ TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
+ bool type_args_cloned = false;
// Clone the signature if this type represents a function type.
const Function& fun = Function::Handle(zone, signature());
if (!fun.IsNull()) {
+ // If the scope class is not a typedef and if it is generic, it must be the
+ // mixin class, set it to the new owner.
+ if (!type_cls.IsTypedefClass() && type_cls.IsGeneric()) {
+ clone.set_type_class(new_owner);
+ AbstractType& decl_type = AbstractType::Handle(zone);
+#ifdef DEBUG
+ decl_type = type_cls.DeclarationType();
+ ASSERT(decl_type.IsFinalized());
+ const TypeArguments& decl_type_args =
+ TypeArguments::Handle(zone, decl_type.arguments());
+ ASSERT(type_args.Equals(decl_type_args));
+#endif // DEBUG
+ decl_type = new_owner.DeclarationType();
+ ASSERT(decl_type.IsFinalized());
+ type_args = decl_type.arguments();
+ clone.set_arguments(type_args);
+ type_args_cloned = true;
+ }
Function& fun_clone = Function::Handle(zone,
Function::NewSignatureFunction(new_owner, TokenPosition::kNoSource));
AbstractType& type = AbstractType::Handle(zone, fun.result_type());
@@ -16813,13 +16833,14 @@ RawAbstractType* Type::CloneUninstantiated(const Class& new_owner,
fun_clone.set_parameter_names(Array::Handle(zone, fun.parameter_names()));
clone.set_signature(fun_clone);
}
- TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
- // Upper bounds of uninstantiated type arguments may form a cycle.
- if (type_args.IsRecursive() || !type_args.IsInstantiated()) {
- AddOnlyBuddyToTrail(&trail, clone);
+ if (!type_args_cloned) {
+ // Upper bounds of uninstantiated type arguments may form a cycle.
+ if (type_args.IsRecursive() || !type_args.IsInstantiated()) {
+ AddOnlyBuddyToTrail(&trail, clone);
+ }
+ type_args = type_args.CloneUninstantiated(new_owner, trail);
+ clone.set_arguments(type_args);
}
- type_args = type_args.CloneUninstantiated(new_owner, trail);
- clone.set_arguments(type_args);
clone.SetIsFinalized();
return clone.raw();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698