| Index: tool/input_sdk/private/ddc_runtime/operations.dart
|
| diff --git a/tool/input_sdk/private/ddc_runtime/operations.dart b/tool/input_sdk/private/ddc_runtime/operations.dart
|
| index b9a324d7792a0b58e0599dda5fb1730680ddb3cc..278b2513b9510db480e134efca7fefa797e7907e 100644
|
| --- a/tool/input_sdk/private/ddc_runtime/operations.dart
|
| +++ b/tool/input_sdk/private/ddc_runtime/operations.dart
|
| @@ -261,8 +261,19 @@ cast(obj, type) {
|
| }
|
|
|
| bool test(obj) {
|
| - if (JS('bool', 'typeof # == "boolean"', obj)) return JS('bool', '#', obj);
|
| - throwCastError(getReifiedType(obj), JS('', '#', bool));
|
| + if (obj is bool) return obj;
|
| + return booleanConversionFailed(obj);
|
| +}
|
| +
|
| +bool booleanConversionFailed(obj) {
|
| + if (obj == null) {
|
| + throw new BooleanConversionAssertionError();
|
| + }
|
| + var actual = getReifiedType(obj);
|
| + var expected = JS('', '#', bool);
|
| + throw new TypeErrorImplementation.fromMessage(
|
| + "type '${typeName(actual)}' is not a subtype of "
|
| + "type '${typeName(expected)}' in boolean expression");
|
| }
|
|
|
| void _throwCastError(obj, type, bool result) {
|
|
|