| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index df187945a3d15acff60c8c1efeaaefc79904287f..3a3fb9ecc0df259145d781c3240a9677e1f9f0a4 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -4921,6 +4921,22 @@ RawTypeArguments* TypeArguments::Canonicalize(TrailPtr trail) const {
|
| }
|
|
|
|
|
| +RawString* TypeArguments::EnumerateURIs() const {
|
| + if (IsNull()) {
|
| + return Symbols::Empty().raw();
|
| + }
|
| + Zone* zone = Thread::Current()->zone();
|
| + AbstractType& type = AbstractType::Handle(zone);
|
| + const intptr_t num_types = Length();
|
| + GrowableHandlePtrArray<const String> pieces(zone, num_types);
|
| + for (intptr_t i = 0; i < num_types; i++) {
|
| + type = TypeAt(i);
|
| + pieces.Add(String::Handle(zone, type.EnumerateURIs()));
|
| + }
|
| + return Symbols::FromConcatAll(pieces);
|
| +}
|
| +
|
| +
|
| const char* TypeArguments::ToCString() const {
|
| if (IsNull()) {
|
| return "NULL TypeArguments";
|
| @@ -14847,6 +14863,13 @@ RawAbstractType* AbstractType::Canonicalize(TrailPtr trail) const {
|
| }
|
|
|
|
|
| +RawString* AbstractType::EnumerateURIs() const {
|
| + // AbstractType is an abstract class.
|
| + UNREACHABLE();
|
| + return NULL;
|
| +}
|
| +
|
| +
|
| RawAbstractType* AbstractType::OnlyBuddyInTrail(TrailPtr trail) const {
|
| if (trail == NULL) {
|
| return AbstractType::null();
|
| @@ -15043,6 +15066,29 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
|
| }
|
|
|
|
|
| +// Same as user visible name, but including the URI of each occuring type.
|
| +// Used to report errors involving types with identical names.
|
| +//
|
| +// e.g.
|
| +// MyClass<String> -> MyClass<String> where
|
| +// MyClass is from my_uri
|
| +// String is from dart:core
|
| +// MyClass<dynamic, T> -> MyClass<dynamic, T> where
|
| +// MyClass is from my_uri
|
| +// T of OtherClass is from other_uri
|
| +// (MyClass) => int -> (MyClass) => int where
|
| +// MyClass is from my_uri
|
| +// int is from dart:core
|
| +RawString* AbstractType::UserVisibleNameWithURI() const {
|
| + Zone* zone = Thread::Current()->zone();
|
| + GrowableHandlePtrArray<const String> pieces(zone, 3);
|
| + pieces.Add(String::Handle(zone, BuildName(kUserVisibleName)));
|
| + pieces.Add(Symbols::SpaceWhereNewLine());
|
| + pieces.Add(String::Handle(zone, EnumerateURIs()));
|
| + return Symbols::FromConcatAll(pieces);
|
| +}
|
| +
|
| +
|
| RawString* AbstractType::ClassName() const {
|
| if (HasResolvedTypeClass()) {
|
| return Class::Handle(type_class()).Name();
|
| @@ -15787,6 +15833,25 @@ RawAbstractType* Type::Canonicalize(TrailPtr trail) const {
|
| }
|
|
|
|
|
| +RawString* Type::EnumerateURIs() const {
|
| + if (IsDynamicType()) {
|
| + return Symbols::Empty().raw();
|
| + }
|
| + Zone* zone = Thread::Current()->zone();
|
| + GrowableHandlePtrArray<const String> pieces(zone, 6);
|
| + const Class& cls = Class::Handle(zone, type_class());
|
| + pieces.Add(Symbols::TwoSpaces());
|
| + pieces.Add(String::Handle(zone, cls.UserVisibleName()));
|
| + pieces.Add(Symbols::SpaceIsFromSpace());
|
| + const Library& library = Library::Handle(zone, cls.library());
|
| + pieces.Add(String::Handle(zone, library.url()));
|
| + pieces.Add(Symbols::NewLine());
|
| + const TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
|
| + pieces.Add(String::Handle(zone, type_args.EnumerateURIs()));
|
| + return Symbols::FromConcatAll(pieces);
|
| +}
|
| +
|
| +
|
| intptr_t Type::Hash() const {
|
| ASSERT(IsFinalized());
|
| uint32_t result = 1;
|
| @@ -16278,6 +16343,28 @@ RawAbstractType* FunctionType::Canonicalize(TrailPtr trail) const {
|
| }
|
|
|
|
|
| +RawString* FunctionType::EnumerateURIs() const {
|
| + Zone* zone = Thread::Current()->zone();
|
| + // The scope class and type arguments do not appear explicitly in the user
|
| + // visible name. The type arguments were used to instantiate the function type
|
| + // prior to this call.
|
| + const Function& sig_fun = Function::Handle(zone, signature());
|
| + AbstractType& type = AbstractType::Handle(zone);
|
| + const intptr_t num_params = sig_fun.NumParameters();
|
| + GrowableHandlePtrArray<const String> pieces(zone, num_params + 1);
|
| + for (intptr_t i = 0; i < num_params; i++) {
|
| + type = sig_fun.ParameterTypeAt(i);
|
| + pieces.Add(String::Handle(zone, type.EnumerateURIs()));
|
| + }
|
| + // Handle result type last, since it appears last in the user visible name.
|
| + type = sig_fun.result_type();
|
| + if (!type.IsDynamicType() && !type.IsVoidType()) {
|
| + pieces.Add(String::Handle(zone, type.EnumerateURIs()));
|
| + }
|
| + return Symbols::FromConcatAll(pieces);
|
| +}
|
| +
|
| +
|
| intptr_t FunctionType::Hash() const {
|
| ASSERT(IsFinalized());
|
| uint32_t result = 1;
|
| @@ -16481,6 +16568,11 @@ RawAbstractType* TypeRef::Canonicalize(TrailPtr trail) const {
|
| }
|
|
|
|
|
| +RawString* TypeRef::EnumerateURIs() const {
|
| + return Symbols::Empty().raw(); // Break cycle.
|
| +}
|
| +
|
| +
|
| intptr_t TypeRef::Hash() const {
|
| // Do not calculate the hash of the referenced type to avoid divergence.
|
| const uint32_t result =
|
| @@ -16696,6 +16788,22 @@ RawAbstractType* TypeParameter::CloneUninstantiated(
|
| }
|
|
|
|
|
| +RawString* TypeParameter::EnumerateURIs() const {
|
| + Zone* zone = Thread::Current()->zone();
|
| + GrowableHandlePtrArray<const String> pieces(zone, 4);
|
| + pieces.Add(Symbols::TwoSpaces());
|
| + pieces.Add(String::Handle(zone, name()));
|
| + pieces.Add(Symbols::SpaceOfSpace());
|
| + const Class& cls = Class::Handle(zone, parameterized_class());
|
| + pieces.Add(String::Handle(zone, cls.UserVisibleName()));
|
| + pieces.Add(Symbols::SpaceIsFromSpace());
|
| + const Library& library = Library::Handle(zone, cls.library());
|
| + pieces.Add(String::Handle(zone, library.url()));
|
| + pieces.Add(Symbols::NewLine());
|
| + return Symbols::FromConcatAll(pieces);
|
| +}
|
| +
|
| +
|
| intptr_t TypeParameter::Hash() const {
|
| ASSERT(IsFinalized());
|
| uint32_t result = Class::Handle(parameterized_class()).id();
|
| @@ -16948,6 +17056,12 @@ RawAbstractType* BoundedType::CloneUninstantiated(
|
| }
|
|
|
|
|
| +RawString* BoundedType::EnumerateURIs() const {
|
| + // The bound does not appear in the user visible name.
|
| + return AbstractType::Handle(type()).EnumerateURIs();
|
| +}
|
| +
|
| +
|
| intptr_t BoundedType::Hash() const {
|
| uint32_t result = AbstractType::Handle(type()).Hash();
|
| // No need to include the hash of the bound, since the bound is defined by the
|
|
|