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

Unified Diff: runtime/vm/code_generator.cc

Issue 128803003: Fix issue 14366: in case of a type check error and conflicting type names being the same, prefix ty… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 31614)
+++ runtime/vm/code_generator.cc (working copy)
@@ -616,22 +616,41 @@
// Throw a dynamic type error.
const intptr_t location = GetCallerLocation();
const AbstractType& src_type = AbstractType::Handle(src_instance.GetType());
- const String& src_type_name = String::Handle(src_type.UserVisibleName());
+ String& src_type_name = String::Handle(src_type.UserVisibleName());
String& dst_type_name = String::Handle();
+ Library& dst_type_lib = Library::Handle();
if (!dst_type.IsInstantiated()) {
// Instantiate dst_type before reporting the error.
const AbstractType& instantiated_dst_type = AbstractType::Handle(
dst_type.InstantiateFrom(instantiator_type_arguments, NULL));
// Note that instantiated_dst_type may be malbounded.
dst_type_name = instantiated_dst_type.UserVisibleName();
+ dst_type_lib =
+ Class::Handle(instantiated_dst_type.type_class()).library();
} else {
dst_type_name = dst_type.UserVisibleName();
+ dst_type_lib = Class::Handle(dst_type.type_class()).library();
}
String& bound_error_message = String::Handle();
if (!bound_error.IsNull()) {
ASSERT(FLAG_enable_type_checks);
bound_error_message = String::New(bound_error.ToErrorCString());
}
+ if (src_type_name.Equals(dst_type_name)) {
+ // Qualify the names with their libraries.
+ String& lib_name = String::Handle();
+ lib_name = Library::Handle(
+ Class::Handle(src_type.type_class()).library()).name();
+ if (lib_name.Length() != 0) {
+ lib_name = String::Concat(lib_name, Symbols::Dot());
+ src_type_name = String::Concat(lib_name, src_type_name);
+ }
+ lib_name = dst_type_lib.name();
+ if (lib_name.Length() != 0) {
+ lib_name = String::Concat(lib_name, Symbols::Dot());
+ dst_type_name = String::Concat(lib_name, dst_type_name);
+ }
+ }
Exceptions::CreateAndThrowTypeError(location, src_type_name, dst_type_name,
dst_name, bound_error_message);
UNREACHABLE();
« 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