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

Unified Diff: lib/compiler/implementation/js_backend/constant_system_javascript.dart

Issue 10916232: Implement checked mode for const constructors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « lib/compiler/implementation/constant_system_dart.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/js_backend/constant_system_javascript.dart
===================================================================
--- lib/compiler/implementation/js_backend/constant_system_javascript.dart (revision 12366)
+++ lib/compiler/implementation/js_backend/constant_system_javascript.dart (working copy)
@@ -217,4 +217,15 @@
bool isString(Constant constant) => constant.isString();
bool isBool(Constant constant) => constant.isBool();
bool isNull(Constant constant) => constant.isNull();
-}
+
+ bool isSubtype(Compiler compiler, DartType s, DartType t) {
+ // At runtime, an integer is both an integer and a double: the
+ // integer type check is Math.floor, which will return true only
+ // for real integers, and our double type check is 'typeof number'
+ // which will return true for both integers and doubles.
+ if (s.element == compiler.intClass && t.element == compiler.doubleClass) {
+ return true;
+ }
+ return compiler.types.isSubtype(s, t);
+ }
+}
« no previous file with comments | « lib/compiler/implementation/constant_system_dart.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698