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

Side by Side Diff: runtime/lib/errors_patch.dart

Issue 2785623004: Fix #14144 confusing error message misusing a callable object (Closed)
Patch Set: Remove the check to 'call' methods to report closures. Clearer this way. Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 @patch 5 @patch
6 class Error { 6 class Error {
7 @patch 7 @patch
8 static String _objectToString(Object object) { 8 static String _objectToString(Object object) {
9 return Object._toString(object); 9 return Object._toString(object);
10 } 10 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 { 305 {
306 if (_receiver == null) { 306 if (_receiver == null) {
307 if (args_mismatch) { 307 if (args_mismatch) {
308 msg_buf.writeln("The null object does not have a $type_str " 308 msg_buf.writeln("The null object does not have a $type_str "
309 "'$memberName'$args_message."); 309 "'$memberName'$args_message.");
310 } else { 310 } else {
311 msg_buf 311 msg_buf
312 .writeln("The $type_str '$memberName' was called on null."); 312 .writeln("The $type_str '$memberName' was called on null.");
313 } 313 }
314 } else { 314 } else {
315 if (_receiver is Function) { 315 if (_receiver.runtimeType == Function ||
rmacnak 2017/03/31 16:36:39 `_receiver.runtimeType == Function` doesn't match
316 _receiver.runtimeType == _Closure) {
316 msg_buf.writeln("Closure call with mismatched arguments: " 317 msg_buf.writeln("Closure call with mismatched arguments: "
317 "function '$memberName'"); 318 "function '$memberName'");
318 } else if (_receiver is _Type && memberName == "call") { 319 } else if (_receiver is _Type && memberName == "call") {
319 is_type_call = true; 320 is_type_call = true;
320 String name = _receiver.toString(); 321 String name = _receiver.toString();
321 msg_buf.writeln("Attempted to use type '$name' as a function. " 322 msg_buf.writeln("Attempted to use type '$name' as a function. "
322 "Since types do not define a method 'call', this is not " 323 "Since types do not define a method 'call', this is not "
323 "possible. Did you intend to call the $name constructor and " 324 "possible. Did you intend to call the $name constructor and "
324 "forget the 'new' operator?"); 325 "forget the 'new' operator?");
325 } else { 326 } else {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 389
389 return msg_buf.toString(); 390 return msg_buf.toString();
390 } 391 }
391 } 392 }
392 393
393 class _CompileTimeError extends Error { 394 class _CompileTimeError extends Error {
394 final String _errorMsg; 395 final String _errorMsg;
395 _CompileTimeError(this._errorMsg); 396 _CompileTimeError(this._errorMsg);
396 String toString() => _errorMsg; 397 String toString() => _errorMsg;
397 } 398 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_inliner.cc » ('j') | tests/language/vm/no_such_args_error_message_vm_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698