Chromium Code Reviews| 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(); |
| } |
| /** |