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

Unified Diff: runtime/lib/errors_patch.dart

Issue 14652008: Fix error reporting when calling static methods and closures withh mismatched arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « no previous file | runtime/lib/object.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 22181)
+++ runtime/lib/errors_patch.dart (working copy)
@@ -23,7 +23,12 @@
numPositionalArguments -= numNamedArguments;
List positionalArguments;
if (numPositionalArguments == 0) {
- positionalArguments = [];
+ // Differ between no arguments specified and 0 arguments.
+ // TODO(srdjan): This can currently occur for unresolvable static methods.
+ // In that case, the arguments are evaluated but not passed to the
+ // throwing stub (see EffectGraphVisitor::BuildThrowNoSuchMethodError and
+ // Parser::ThrowNoSuchMethodError)).
+ positionalArguments = argumentNames == null ? null : [];
} else {
positionalArguments = arguments.sublist(0, numPositionalArguments);
}
@@ -79,8 +84,13 @@
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.";
+ if (_receiver is Function) {
+ msg = "Closure call with mismatched arguments: "
+ "function '$_memberName'";
+ } else {
+ msg = "Class '${_receiver.runtimeType}' has no instance $type_str "
+ "'$_memberName'$args_message.";
+ }
}
break;
}
@@ -94,7 +104,7 @@
break;
}
case _InvocationMirror._TOP_LEVEL: {
- msg = "No top-level $type_str '$_memberName' declared.";
+ msg = "No top-level $type_str '$_memberName'$args_message declared.";
break;
}
}
@@ -104,7 +114,12 @@
/* patch */ String toString() {
StringBuffer actual_buf = new StringBuffer();
int i = 0;
- if (_arguments != null) {
+ if (_arguments == null) {
+ // Actual arguments unknown.
+ // TODO(srdjan): Remove once arguments are passed for unresolvable
+ // static methods.
+ actual_buf.write("...");
+ } else {
for (; i < _arguments.length; i++) {
if (i > 0) {
actual_buf.write(", ");
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698