| Index: runtime/vm/exceptions.cc
|
| ===================================================================
|
| --- runtime/vm/exceptions.cc (revision 9048)
|
| +++ runtime/vm/exceptions.cc (working copy)
|
| @@ -182,13 +182,21 @@
|
| const String& dst_type_name,
|
| const String& dst_name,
|
| const String& malformed_error) {
|
| - // Allocate a new instance of TypeError.
|
| - const Instance& type_error = Instance::Handle(NewInstance("TypeError"));
|
| + // Allocate a new instance of TypeError or CastException.
|
| + Instance& type_error = Instance::Handle();
|
| + Class& cls = Class::Handle();
|
| + if (dst_name.Equals("type cast")) {
|
| + type_error = NewInstance("CastException");
|
| + cls = type_error.clazz();
|
| + cls = cls.SuperClass();
|
| + } else {
|
| + type_error = NewInstance("TypeError");
|
| + cls = type_error.clazz();
|
| + }
|
|
|
| // Initialize 'url', 'line', and 'column' fields.
|
| DartFrameIterator iterator;
|
| const Script& script = Script::Handle(GetCallerScript(&iterator));
|
| - const Class& cls = Class::Handle(type_error.clazz());
|
| // Location fields are defined in AssertionError, the superclass of TypeError.
|
| const Class& assertion_error_class = Class::Handle(cls.SuperClass());
|
| SetLocationFields(type_error, assertion_error_class, script, location);
|
|
|