diff --git a/ets2panda/compiler/lowering/ets/unboxLowering.cpp b/ets2panda/compiler/lowering/ets/unboxLowering.cpp index 9826b156f30249cac42fb0f75a06c7223f92ea22..a2b945c3c4c08beba591bc25d678c72a6084eec3 100644 --- a/ets2panda/compiler/lowering/ets/unboxLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unboxLowering.cpp @@ -485,12 +485,31 @@ static ir::Expression *InsertPrimitiveConversionIfNeeded(UnboxContext *uctx, ir: toConvert = tp; } }; - checkSubtyping(checker->GlobalByteBuiltinType()); - checkSubtyping(checker->GlobalShortBuiltinType()); - checkSubtyping(checker->GlobalIntBuiltinType()); - checkSubtyping(checker->GlobalLongBuiltinType()); - checkSubtyping(checker->GlobalFloatBuiltinType()); - checkSubtyping(checker->GlobalDoubleBuiltinType()); + + switch (checker->ETSType(MaybeRecursivelyUnboxType(uctx, actualType))) { + case checker::TypeFlag::BYTE: + checkSubtyping(checker->GlobalByteBuiltinType()); + [[fallthrough]]; + case checker::TypeFlag::SHORT: + checkSubtyping(checker->GlobalShortBuiltinType()); + [[fallthrough]]; + case checker::TypeFlag::CHAR: + case checker::TypeFlag::INT: + checkSubtyping(checker->GlobalIntBuiltinType()); + [[fallthrough]]; + case checker::TypeFlag::LONG: + checkSubtyping(checker->GlobalLongBuiltinType()); + [[fallthrough]]; + case checker::TypeFlag::FLOAT: + checkSubtyping(checker->GlobalFloatBuiltinType()); + [[fallthrough]]; + case checker::TypeFlag::DOUBLE: + checkSubtyping(checker->GlobalDoubleBuiltinType()); + [[fallthrough]]; + default: + break; + } + if (toConvert == nullptr && actualType->IsCharType() && relation->IsSupertypeOf(expectedType, checker->GlobalBuiltinETSStringType())) { toConvert = uctx->checker->GlobalBuiltinETSStringType();