diff --git a/pkg/dart2wasm/lib/translator.dart b/pkg/dart2wasm/lib/translator.dart index 4e6c7e208f7..dfcd9baaf49 100644 --- a/pkg/dart2wasm/lib/translator.dart +++ b/pkg/dart2wasm/lib/translator.dart @@ -875,8 +875,20 @@ class Translator with KernelNodes { } } else if (to is w.RefType) { // Boxing - ClassInfo info = classInfo[boxedClasses[from]!]!; + Class cls = boxedClasses[from]!; + ClassInfo info = classInfo[cls]!; assert(info.struct.isSubtypeOf(to.heapType)); + + if (cls == boxedBoolClass) { + final constantType = w.RefType(info.struct, nullable: false); + b.if_([], [constantType]); + constants.instantiateConstant(b, BoolConstant(true), constantType); + b.else_(); + constants.instantiateConstant(b, BoolConstant(false), constantType); + b.end(); + return; + } + w.Local temp = b.addLocal(from); b.local_set(temp); b.i32_const(info.classId);