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

Unified Diff: runtime/lib/errors_patch.dart

Issue 21832003: Fix VM implementation of CastError not to extend TypeError (issue 5280). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | « runtime/lib/errors.cc ('k') | runtime/lib/stacktrace.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/errors_patch.dart
===================================================================
--- runtime/lib/errors_patch.dart (revision 25781)
+++ runtime/lib/errors_patch.dart (working copy)
@@ -12,6 +12,118 @@
StackTrace _stackTrace;
}
+patch class AssertionError extends Error {
+ AssertionError._create(
+ this._failedAssertion, this._url, this._line, this._column);
+
+ static _throwNew(int assertionStart, int assertionEnd)
+ native "AssertionError_throwNew";
+
+ String toString() {
+ return "'$_url': Failed assertion: line $_line pos $_column: "
+ "'$_failedAssertion' is not true.";
+ }
+ final String _failedAssertion;
+ final String _url;
+ final int _line;
+ final int _column;
+}
+
+patch class TypeError extends AssertionError {
+ TypeError._create(String url, int line, int column,
+ this._srcType, this._dstType, this._dstName,
+ this._malformedError)
+ : super._create("is assignable", url, line, column);
+
+ static _throwNew(int location,
+ Object src_value,
+ String dst_type_name,
+ String dst_name,
+ String malformed_error)
+ native "TypeError_throwNew";
+
+ String toString() {
+ String str = (_malformedError != null) ? _malformedError : "";
+ if ((_dstName != null) && (_dstName.length > 0)) {
+ str = "${str}type '$_srcType' is not a subtype of "
+ "type '$_dstType' of '$_dstName'.";
+ } else {
+ str = "${str}malformed type used.";
+ }
+ return str;
+ }
+
+ final String _srcType;
+ final String _dstType;
+ final String _dstName;
+ final String _malformedError;
+}
+
+patch class CastError extends Error {
+ CastError._create(this._url, this._line, this._column,
+ this._srcType, this._dstType, this._dstName,
+ this._malformedError);
+
+ // A CastError is allocated by TypeError._throwNew() when dst_name equals
+ // Exceptions::kCastErrorDstName.
+
+ String toString() {
+ String str = (_malformedError != null) ? _malformedError : "";
+ str = "${str}type '$_srcType' is not a subtype of "
+ "type '$_dstType' in type cast.";
+ return str;
+ }
+
+ // Fields _url, _line, and _column are only used for debugging purposes.
+ final String _url;
+ final int _line;
+ final int _column;
+ final String _srcType;
+ final String _dstType;
+ final String _dstName;
+ final String _malformedError;
+}
+
+patch class FallThroughError {
+ FallThroughError._create(this._url, this._line);
+
+ static _throwNew(int case_clause_pos) native "FallThroughError_throwNew";
+
+ /* patch */ String toString() {
+ return "'$_url': Switch case fall-through at line $_line.";
+ }
+
+ // These new fields cannot be declared final, because a constructor exists
+ // in the original version of this patched class.
+ String _url;
+ int _line;
+}
+
+class _InternalError {
+ const _InternalError(this._msg);
+ String toString() => "InternalError: '${_msg}'";
+ final String _msg;
+}
+
+
+patch class AbstractClassInstantiationError {
+ AbstractClassInstantiationError._create(
+ this._className, this._url, this._line);
+
+ static _throwNew(int case_clause_pos, String className)
+ native "AbstractClassInstantiationError_throwNew";
+
+ /* patch */ String toString() {
+ return "Cannot instantiate abstract class $_className: "
+ "_url '$_url' line $_line";
+ }
+
+ // These new fields cannot be declared final, because a constructor exists
+ // in the original version of this patched class.
+ String _url;
+ int _line;
+}
+
patch class NoSuchMethodError {
// The compiler emits a call to _throwNew when it cannot resolve a static
// method at compile time. The receiver is actually the literal class of the
« no previous file with comments | « runtime/lib/errors.cc ('k') | runtime/lib/stacktrace.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698