| Index: runtime/vm/exceptions.cc
|
| ===================================================================
|
| --- runtime/vm/exceptions.cc (revision 28940)
|
| +++ runtime/vm/exceptions.cc (working copy)
|
| @@ -491,15 +491,17 @@
|
|
|
|
|
| // Allocate, initialize, and throw a TypeError or CastError.
|
| +// If bound_error is not null, throw a TypeError, even for a type cast.
|
| void Exceptions::CreateAndThrowTypeError(intptr_t location,
|
| const String& src_type_name,
|
| const String& dst_type_name,
|
| const String& dst_name,
|
| - const String& malformed_error) {
|
| + const String& bound_error) {
|
| const Array& args = Array::Handle(Array::New(7));
|
|
|
| ExceptionType exception_type =
|
| - dst_name.Equals(kCastErrorDstName) ? kCast : kType;
|
| + (bound_error.IsNull() && dst_name.Equals(kCastErrorDstName)) ?
|
| + kCast : kType;
|
|
|
| DartFrameIterator iterator;
|
| const Script& script = Script::Handle(GetCallerScript(&iterator));
|
| @@ -510,17 +512,17 @@
|
| args.SetAt(1, Smi::Handle(Smi::New(line)));
|
| args.SetAt(2, Smi::Handle(Smi::New(column)));
|
|
|
| - // Initialize '_srcType', '_dstType', '_dstName', and '_malformedError'.
|
| + // Initialize '_srcType', '_dstType', '_dstName', and '_boundError'.
|
| args.SetAt(3, src_type_name);
|
| args.SetAt(4, dst_type_name);
|
| args.SetAt(5, dst_name);
|
| - args.SetAt(6, malformed_error);
|
| + args.SetAt(6, bound_error);
|
|
|
| // Type errors in the core library may be difficult to diagnose.
|
| // Print type error information before throwing the error when debugging.
|
| if (FLAG_print_stacktrace_at_throw) {
|
| - if (!malformed_error.IsNull()) {
|
| - OS::Print("%s\n", malformed_error.ToCString());
|
| + if (!bound_error.IsNull()) {
|
| + OS::Print("%s\n", bound_error.ToCString());
|
| }
|
| intptr_t line, column;
|
| script.GetTokenLocation(location, &line, &column);
|
| @@ -532,7 +534,7 @@
|
| dst_type_name.ToCString(),
|
| dst_name.ToCString());
|
| } else {
|
| - OS::Print("malformed type used.\n");
|
| + OS::Print("malbounded type used.\n");
|
| }
|
| }
|
| // Throw TypeError or CastError instance.
|
|
|