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

Unified Diff: lib/runtime/dart/math.js

Issue 1117793002: add checks needed for covariant generics, and List<E> (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 | « lib/runtime/dart/core.js ('k') | lib/runtime/dart_runtime.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart/math.js
diff --git a/lib/runtime/dart/math.js b/lib/runtime/dart/math.js
index b167cdec406e5d50f9df2dddbcf09536f6d8b1c8..16abfaec7497520753be012e76dc80c88c9414a1 100644
--- a/lib/runtime/dart/math.js
+++ b/lib/runtime/dart/math.js
@@ -37,9 +37,11 @@ var math;
return _JenkinsSmiHash.hash2(dart.hashCode(this.x), dart.hashCode(this.y));
}
['+'](other) {
+ dart.as(other, Point$(T));
return new (Point$(T))(dart.as(this.x['+'](other.x), T), dart.as(this.y['+'](other.y), T));
}
['-'](other) {
+ dart.as(other, Point$(T));
return new (Point$(T))(dart.as(this.x['-'](other.x), T), dart.as(this.y['-'](other.y), T));
}
['*'](factor) {
@@ -49,11 +51,13 @@ var math;
return sqrt(dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*'](this.y)));
}
distanceTo(other) {
+ dart.as(other, Point$(T));
let dx = this.x['-'](other.x);
let dy = this.y['-'](other.y);
return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy));
}
squaredDistanceTo(other) {
+ dart.as(other, Point$(T));
let dx = this.x['-'](other.x);
let dy = this.y['-'](other.y);
return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy), T);
@@ -91,6 +95,7 @@ var math;
return _JenkinsSmiHash.hash4(dart.hashCode(this.left), dart.hashCode(this.top), dart.hashCode(this.right), dart.hashCode(this.bottom));
}
intersection(other) {
+ dart.as(other, Rectangle$(T));
let x0 = max(this.left, other.left);
let x1 = min(this.left['+'](this.width), other.left['+'](other.width));
if (dart.notNull(x0) <= dart.notNull(x1)) {
@@ -106,6 +111,7 @@ var math;
return dart.notNull(this.left['<='](dart.notNull(other.left) + dart.notNull(other.width))) && dart.notNull(other.left) <= dart.notNull(this.left['+'](this.width)) && dart.notNull(this.top['<='](dart.notNull(other.top) + dart.notNull(other.height))) && dart.notNull(other.top) <= dart.notNull(this.top['+'](this.height));
}
boundingBox(other) {
+ dart.as(other, Rectangle$(T));
let right = max(this.left['+'](this.width), other.left['+'](other.width));
let bottom = max(this.top['+'](this.height), other.top['+'](other.height));
let left = min(this.left, other.left);
@@ -177,6 +183,7 @@ var math;
return this[_width];
}
set width(width) {
+ dart.as(width, T);
if (width['<'](0))
width = dart.as(_clampToZero(width), T);
this[_width] = width;
@@ -185,6 +192,7 @@ var math;
return this[_height];
}
set height(height) {
+ dart.as(height, T);
if (height['<'](0))
height = dart.as(_clampToZero(height), T);
this[_height] = height;
« no previous file with comments | « lib/runtime/dart/core.js ('k') | lib/runtime/dart_runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698