Index: runtime/lib/errors_patch.dart |
diff --git a/runtime/lib/errors_patch.dart b/runtime/lib/errors_patch.dart |
index bf0405922f5d7bcce314b3ff7c117fcf186fe3e5..989eb57424f9a6ecece0f7ac88165f0368ae33f6 100644 |
--- a/runtime/lib/errors_patch.dart |
+++ b/runtime/lib/errors_patch.dart |
@@ -273,6 +273,7 @@ class _InternalError { |
} |
StringBuffer msg_buf = new StringBuffer("NoSuchMethodError: "); |
+ bool is_type_call = false; |
switch (level) { |
case _InvocationMirror._DYNAMIC: { |
if (_receiver == null) { |
@@ -286,6 +287,13 @@ class _InternalError { |
if (_receiver is Function) { |
msg_buf.writeln("Closure call with mismatched arguments: " |
"function '$memberName'"); |
+ } else if (_receiver is _Type && memberName == "call") { |
+ is_type_call = true; |
+ String name = _receiver.toString(); |
+ msg_buf.writeln("Attempted to use type '$name' as a function. " |
+ "Since types do not define a method 'call', this is not " |
+ "possible. Did you intend to call the $name constructor and " |
+ "forget the 'new' operator?"); |
} else { |
msg_buf.writeln("Class '${_receiver.runtimeType}' has no instance " |
"$type_str '$memberName'$args_message."); |
@@ -324,7 +332,8 @@ class _InternalError { |
} |
if (type == _InvocationMirror._METHOD) { |
- msg_buf.write("Tried calling: $memberName($arguments)"); |
+ String m = is_type_call ? "$_receiver" : "$memberName"; |
+ msg_buf.write("Tried calling: $m($arguments)"); |
} else if (argumentCount == 0) { |
msg_buf.write("Tried calling: $memberName"); |
} else if (type == _InvocationMirror._SETTER) { |