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

Unified Diff: lib/core/errors.dart

Issue 11231074: Change signature of noSuchMethod to take an InvocationMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more test expectation Created 8 years, 2 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 | « lib/compiler/implementation/universe/universe.dart ('k') | lib/core/object.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/core/errors.dart
diff --git a/lib/core/errors.dart b/lib/core/errors.dart
index c9709c9664d8ba3dd5bbb4cad99121e316190290..5cb50f15df20ca633f52e6f9ce26ee7c585b1d56 100644
--- a/lib/core/errors.dart
+++ b/lib/core/errors.dart
@@ -73,39 +73,56 @@ class AbstractClassInstantiationError implements Error {
*/
class NoSuchMethodError implements Error {
final Object _receiver;
- final String _functionName;
+ final String _memberName;
final List _arguments;
+ final Map<String,Dynamic> _namedArguments;
final List _existingArgumentNames;
/**
* Create a [NoSuchMethodError] corresponding to a failed method call.
*
- * The first parameter is the receiver of the method call.
- * The second parameter is the name of the called method.
- * The third parameter is the positional arguments that the method was
- * called with.
+ * The first parameter to this constructor is the receiver of the method call.
+ * That is, the object on which the method was attempted called.
+ * The second parameter is the name of the called method or accessor.
+ * The third parameter is a list of the positional arguments that the method
+ * was called with.
+ * The fourth parameter is a map from [String] names to the values of named
+ * arguments that the method was called with.
* The optional [exisitingArgumentNames] is the expected parameters of a
* method with the same name on the receiver, if available. This is
* the method that would have been called if the parameters had matched.
- *
- * TODO(lrn): This will be rewritten to use mirrors when they are available.
*/
const NoSuchMethodError(Object this._receiver,
- String this._functionName,
+ String this._memberName,
List this._arguments,
+ Map<String,Dynamic> this._namedArguments,
[List existingArgumentNames = null])
: this._existingArgumentNames = existingArgumentNames;
String toString() {
StringBuffer sb = new StringBuffer();
- for (int i = 0; i < _arguments.length; i++) {
- if (i > 0) {
- sb.add(", ");
+ int i = 0;
+ if (_arguments != null) {
+ for (; i < _arguments.length; i++) {
+ if (i > 0) {
+ sb.add(", ");
+ }
+ sb.add(safeToString(_arguments[i]));
}
- sb.add(safeToString(_arguments[i]));
+ }
+ if (_namedArguments != null) {
+ _namedArguments.forEach((String key, var value) {
+ if (i > 0) {
+ sb.add(", ");
+ }
+ sb.add(key);
+ sb.add(": ");
+ sb.add(safeToString(value));
+ i++;
+ });
}
if (_existingArgumentNames === null) {
- return "NoSuchMethodError : method not found: '$_functionName'\n"
+ return "NoSuchMethodError : method not found: '$_memberName'\n"
"Receiver: ${safeToString(_receiver)}\n"
"Arguments: [$sb]";
} else {
@@ -119,10 +136,10 @@ class NoSuchMethodError implements Error {
}
String formalParameters = sb.toString();
return "NoSuchMethodError: incorrect number of arguments passed to "
- "method named '$_functionName'\n"
+ "method named '$_memberName'\n"
"Receiver: ${safeToString(_receiver)}\n"
- "Tried calling: $_functionName($actualParameters)\n"
- "Found: $_functionName($formalParameters)";
+ "Tried calling: $_memberName($actualParameters)\n"
+ "Found: $_memberName($formalParameters)";
}
}
« no previous file with comments | « lib/compiler/implementation/universe/universe.dart ('k') | lib/core/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698