Chromium Code Reviews| Index: sdk/lib/math/math.dart |
| diff --git a/sdk/lib/math/math.dart b/sdk/lib/math/math.dart |
| index 93ec4164426ef8c668b0cf057b9539afe07efa05..4cffa8f59455e0caced02d788e7a7bee9d439dd3 100644 |
| --- a/sdk/lib/math/math.dart |
| +++ b/sdk/lib/math/math.dart |
| @@ -61,6 +61,12 @@ const double SQRT2 = 1.4142135623730951; |
| * is returned. |
| */ |
| num min(num a, num b) { |
| + // These partially redundant type checks improve code quality for dart2js. |
| + // Most of the improvement is at call sites from the inferred non-null num |
| + // return type. |
| + if (a is! num) throw new ArgumentError(a); |
| + if (b is! num) throw new ArgumentError(b); |
|
srdjan
2013/09/26 22:09:50
Please add test that verifies this new/old behavio
|
| + |
| if (a > b) return b; |
| if (a < b) return a; |
| if (b is double) { |
| @@ -90,6 +96,12 @@ num min(num a, num b) { |
| * then it is unspecified which of the two arguments is returned. |
| */ |
| num max(num a, num b) { |
| + // These partially redundant type checks improve code quality for dart2js. |
| + // Most of the improvement is at call sites from the inferred non-null num |
| + // return type. |
| + if (a is! num) throw new ArgumentError(a); |
| + if (b is! num) throw new ArgumentError(b); |
| + |
| if (a > b) return a; |
| if (a < b) return b; |
| if (b is double) { |