Index: runtime/lib/integers_patch.dart |
diff --git a/runtime/lib/integers_patch.dart b/runtime/lib/integers_patch.dart |
index fb749d752185b8fe865c559c3e9b0ab923d0a1e6..fab603f03eca71b21c3b7fe088aeb40adcaa6f9e 100644 |
--- a/runtime/lib/integers_patch.dart |
+++ b/runtime/lib/integers_patch.dart |
@@ -74,20 +74,21 @@ patch class int { |
/* patch */ static int parse(String source, |
{ int radix, |
int onError(String str) }) { |
- if ((radix == null) && (onError == null)) return _parse(source); |
+ if (radix == null) { |
+ int result = _parse(source); |
+ if (result == null) { |
+ if (onError == null) { |
+ throw new FormatException(source); |
+ } |
+ return onError(source); |
+ } |
+ return result; |
+ } |
return _slowParse(source, radix, onError); |
} |
static int _slowParse(String source, int radix, int onError(String str)) { |
if (source is! String) throw new ArgumentError(source); |
- if (radix == null) { |
- assert(onError != null); |
- try { |
- return _parse(source); |
- } on FormatException { |
- return onError(source); |
- } |
- } |
if (radix is! int) throw new ArgumentError("Radix is not an integer"); |
if (radix < 2 || radix > 36) { |
throw new RangeError("Radix $radix not in range 2..36"); |