Make sure the bound of a mixin type parameter is finalized before instantiating

it during finalization (fix issue 23385).
Print more info in ToCString() for an unresolved type.

Review URL: https://codereview.chromium.org//1124253004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45598 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
regis@google.com 2015-05-07 16:08:11 +00:00
parent a3366361de
commit 52b19e2b14
2 changed files with 39 additions and 34 deletions

View file

@ -1683,6 +1683,13 @@ void ClassFinalizer::CloneMixinAppTypeParameters(const Class& mixin_app_class) {
param ^= mixin_type_args.TypeAt(i);
param_bound = param.bound();
if (!param_bound.IsInstantiated()) {
// Make sure the bound is finalized before instantiating it.
if (!param_bound.IsFinalized() &&
!param_bound.IsBeingFinalized()) {
param_bound =
FinalizeType(mixin_app_class, param_bound, kCanonicalize);
param.set_bound(param_bound); // In case part of recursive type.
}
param_bound = param_bound.InstantiateFrom(mixin_type_args,
&bound_error);
// The instantiator contains only TypeParameter objects and no

View file

@ -15101,41 +15101,39 @@ void Type::set_type_state(int8_t state) const {
const char* Type::ToCString() const {
if (IsResolved()) {
const TypeArguments& type_arguments = TypeArguments::Handle(arguments());
const char* class_name;
if (HasResolvedTypeClass()) {
class_name = String::Handle(
Class::Handle(type_class()).Name()).ToCString();
} else {
class_name = UnresolvedClass::Handle(unresolved_class()).ToCString();
}
if (type_arguments.IsNull()) {
const char* format = "Type: class '%s'";
const intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1;
char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, class_name);
return chars;
} else if (IsFinalized() && IsRecursive()) {
const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]";
const intptr_t hash = Hash();
const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
const intptr_t len =
OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1;
char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr);
return chars;
} else {
const char* format = "Type: class '%s', args:[%s]";
const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
const intptr_t len =
OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1;
char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, class_name, args_cstr);
return chars;
}
const char* unresolved = IsResolved() ? "" : "Unresolved ";
const TypeArguments& type_arguments = TypeArguments::Handle(arguments());
const char* class_name;
if (HasResolvedTypeClass()) {
class_name = String::Handle(
Class::Handle(type_class()).Name()).ToCString();
} else {
return "Unresolved Type";
class_name = UnresolvedClass::Handle(unresolved_class()).ToCString();
}
if (type_arguments.IsNull()) {
const char* format = "%sType: class '%s'";
const intptr_t len =
OS::SNPrint(NULL, 0, format, unresolved, class_name) + 1;
char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, unresolved, class_name);
return chars;
} else if (IsResolved() && IsFinalized() && IsRecursive()) {
const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]";
const intptr_t hash = Hash();
const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
const intptr_t len =
OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1;
char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr);
return chars;
} else {
const char* format = "%sType: class '%s', args:[%s]";
const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
const intptr_t len =
OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1;
char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr);
return chars;
}
}