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

Unified Diff: pkg/dev_compiler/tool/input_sdk/lib/math/math.dart

Issue 2386493003: Fix type errors in math.min() and math.max(). (Closed)
Patch Set: Created 4 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
Index: pkg/dev_compiler/tool/input_sdk/lib/math/math.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/lib/math/math.dart b/pkg/dev_compiler/tool/input_sdk/lib/math/math.dart
index 73768c934959018dc33a229df54e2d5c9c391df2..0f651b7c933300de01ec43c3c491e555ad450673 100644
--- a/pkg/dev_compiler/tool/input_sdk/lib/math/math.dart
+++ b/pkg/dev_compiler/tool/input_sdk/lib/math/math.dart
@@ -4,9 +4,9 @@
/**
* Mathematical constants and functions, plus a random number generator.
- *
+ *
* To use this library in your code:
- *
+ *
* import 'dart:math';
*/
library dart.math;
@@ -67,32 +67,7 @@ const double SQRT2 = 1.4142135623730951;
* same mathematical value) then it is unspecified which of the two arguments
* is returned.
*/
-num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ 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 b;
- if (a < b) return a;
- if (b is double) {
- // Special case for NaN and -0.0. If one argument is NaN return NaN.
- // [min] must also distinguish between -0.0 and 0.0.
- if (a is double) {
- if (a == 0.0) {
- // a is either 0.0 or -0.0. b is either 0.0, -0.0 or NaN.
- // The following returns -0.0 if either a or b is -0.0, and it
- // returns NaN if b is NaN.
- return (a + b) * a * b;
- }
- }
- // Check for NaN and b == -0.0.
- if (a == 0 && b.isNegative || b.isNaN) return b;
- return a;
- }
- return a;
-}
+external num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b);
/**
* Returns the larger of two numbers.
@@ -102,34 +77,7 @@ num/*=T*/ min/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b) {
* otherwise equal (including int and doubles with the same mathematical value)
* then it is unspecified which of the two arguments is returned.
*/
-num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ 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) {
- // Special case for NaN and -0.0. If one argument is NaN return NaN.
- // [max] must also distinguish between -0.0 and 0.0.
- if (a is double) {
- if (a == 0.0) {
- // a is either 0.0 or -0.0. b is either 0.0, -0.0, or NaN.
- // The following returns 0.0 if either a or b is 0.0, and it
- // returns NaN if b is NaN.
- return a + b;
- }
- }
- // Check for NaN.
- if (b.isNaN) return b;
- return a;
- }
- // max(-0.0, 0) must return 0.
- if (b == 0 && a.isNegative) return b;
- return a;
-}
+external num/*=T*/ max/*<T extends num>*/(num/*=T*/ a, num/*=T*/ b);
/**
* A variant of [atan].

Powered by Google App Engine
This is Rietveld 408576698