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

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
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);
kasperl 2012/09/13 10:34:19 Wouldn't it be more logical to just check that val
ngeoffray 2012/09/13 10:52:32 As discussed, this method is implementing what the
+ 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 | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | lib/compiler/implementation/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698