Index: sdk/lib/core/errors.dart |
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart |
index 0244ea91753d4e98bf7f9d9ff093520e27a22b5d..a67340660307349df0f7f3866c9965b091d7601f 100644 |
--- a/sdk/lib/core/errors.dart |
+++ b/sdk/lib/core/errors.dart |
@@ -300,18 +300,25 @@ class RangeError extends ArgumentError { |
* |
* The [startName] and [endName] defaults to `"start"` and `"end"`, |
* respectively. |
+ * |
+ * Returns the actual `end` value, which is `length` if `end` is `null`, |
+ * and `end` otherwise. |
*/ |
- static void checkValidRange(int start, int end, int length, |
+ static int checkValidRange(int start, int end, int length, |
[String startName, String endName, |
String message]) { |
if (start < 0 || start > length) { |
if (startName == null) startName = "start"; |
throw new RangeError.range(start, 0, length, startName, message); |
} |
- if (end != null && (end < start || end > length)) { |
- if (endName == null) endName = "end"; |
- throw new RangeError.range(end, start, length, endName, message); |
+ if (end != null) { |
+ if (end < start || end > length) { |
+ if (endName == null) endName = "end"; |
+ throw new RangeError.range(end, start, length, endName, message); |
+ } |
+ return end; |
} |
+ return length; |
} |
/** |