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

Unified Diff: dart/lib/compiler/implementation/lib/core_patch.dart

Issue 10939020: Don't invoke user-defined code in NoSuchMethodError.toString. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 8 years, 3 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 | dart/lib/core/errors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/lib/core_patch.dart
diff --git a/dart/lib/compiler/implementation/lib/core_patch.dart b/dart/lib/compiler/implementation/lib/core_patch.dart
index bc881b3391220ec29540977276584feb97808576..70ac1c3ac87b32c5c11be9f9646cf0372033a8c4 100644
--- a/dart/lib/compiler/implementation/lib/core_patch.dart
+++ b/dart/lib/compiler/implementation/lib/core_patch.dart
@@ -65,3 +65,16 @@ patch class int {
patch class double {
patch static double parse(String string) => Primitives.parseDouble(string);
}
+
+patch class NoSuchMethodError {
+ patch static String safeToString(Object object) {
+ if (object is int || object is double || object is bool || null == object) {
+ return object.toString();
+ }
+ if (object is String) {
+ String escaped = object.replaceAll('"', '\\"');
+ return '"$escaped"';
+ }
+ return Primitives.objectToString(object);
+ }
+}
« no previous file with comments | « no previous file | dart/lib/core/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698