| Index: runtime/lib/errors_patch.dart
|
| ===================================================================
|
| --- runtime/lib/errors_patch.dart (revision 18846)
|
| +++ runtime/lib/errors_patch.dart (working copy)
|
| @@ -14,6 +14,7 @@
|
| // unresolved method.
|
| static void _throwNew(Object receiver,
|
| String memberName,
|
| + int invocation_type,
|
| List arguments,
|
| List argumentNames,
|
| List existingArgumentNames) {
|
| @@ -31,20 +32,75 @@
|
| var arg_value = arguments[numPositionalArguments + i];
|
| namedArguments[argumentNames[i]] = arg_value;
|
| }
|
| - throw new NoSuchMethodError(receiver,
|
| + throw new NoSuchMethodError._withType(receiver,
|
| memberName,
|
| + invocation_type,
|
| positionalArguments,
|
| namedArguments,
|
| existingArgumentNames);
|
| }
|
|
|
| + // Remember the type from the invocation mirror or static compilation
|
| + // analysis when thrown directly with _throwNew. A negative value means
|
| + // that no information is available.
|
| + final int _invocation_type;
|
| +
|
| const NoSuchMethodError(Object this._receiver,
|
| String this._memberName,
|
| List this._arguments,
|
| Map<String,dynamic> this._namedArguments,
|
| [List existingArgumentNames = null])
|
| + : this._existingArgumentNames = existingArgumentNames,
|
| + this._invocation_type = -1;
|
| +
|
| + const NoSuchMethodError._withType(Object this._receiver,
|
| + String this._memberName,
|
| + this._invocation_type,
|
| + List this._arguments,
|
| + Map<String,dynamic> this._namedArguments,
|
| + [List existingArgumentNames = null])
|
| : this._existingArgumentNames = existingArgumentNames;
|
|
|
| +
|
| + String _developerMessage(args_mismatch) {
|
| + if (_invocation_type < 0) {
|
| + return "";
|
| + }
|
| + var type = _invocation_type & _InvocationMirror._TYPE_MASK;
|
| + var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) &
|
| + _InvocationMirror._CALL_MASK;
|
| + var type_str =
|
| + (const ["method", "getter", "setter", "getter or setter"])[type];
|
| + var args_message = args_mismatch ? " with matching arguments" : "";
|
| + var msg;
|
| + switch (level) {
|
| + case _InvocationMirror._DYNAMIC: {
|
| + if (_receiver == null) {
|
| + msg = "The null object does not have a $type_str '$_memberName'"
|
| + "$args_message.";
|
| + } else {
|
| + msg = "Class '${_receiver.runtimeType}' has no instance $type_str "
|
| + "'$_memberName'$args_message.";
|
| + }
|
| + break;
|
| + }
|
| + case _InvocationMirror._STATIC: {
|
| + msg = "No static $type_str '$_memberName' declared in class "
|
| + "'$_receiver'.";
|
| + break;
|
| + }
|
| + case _InvocationMirror._CONSTRUCTOR: {
|
| + msg = "No constructor '$_memberName' declared in class '$_receiver'.";
|
| + break;
|
| + }
|
| + case _InvocationMirror._TOP_LEVEL: {
|
| + msg = "No top-level $type_str '$_memberName' declared.";
|
| + break;
|
| + }
|
| + }
|
| + return "$msg\n\n";
|
| + }
|
| +
|
| /* patch */ String toString() {
|
| StringBuffer actual_buf = new StringBuffer();
|
| int i = 0;
|
| @@ -67,8 +123,9 @@
|
| i++;
|
| });
|
| }
|
| - StringBuffer msg_buf = new StringBuffer();
|
| - if (_existingArgumentNames == null) {
|
| + var args_mismatch = _existingArgumentNames != null;
|
| + StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch));
|
| + if (!args_mismatch) {
|
| msg_buf.add(
|
| "NoSuchMethodError : method not found: '$_memberName'\n"
|
| "Receiver: ${Error.safeToString(_receiver)}\n"
|
|
|