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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10905235: Check boolean conversion in checked mode. (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/js_backend/emitter.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
===================================================================
--- lib/compiler/implementation/lib/js_helper.dart (revision 12308)
+++ lib/compiler/implementation/lib/js_helper.dart (working copy)
@@ -977,6 +977,12 @@
* checked mode and casts. We specialize each primitive type (eg int, bool), and
* use the compiler's convention to do is-checks on regular objects.
*/
+boolConversionCheck(value) {
+ boolTypeCheck(value);
+ assert(value !== null);
+ return value;
+}
+
stringTypeCheck(value) {
if (value === null) return value;
if (value is String) return value;
@@ -1260,7 +1266,12 @@
*/
void assert(condition) {
if (condition is Function) condition = condition();
- if (!condition) throw new AssertionError();
+ if (condition is !bool) {
+ throw new TypeErrorImplementation('$condition does not implement bool');
+ }
+ // Compare to true to avoid boolean conversion check in checked
+ // mode.
+ if (condition !== true) throw new AssertionError();
}
/**
« no previous file with comments | « lib/compiler/implementation/js_backend/emitter.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698