From ae782c988f8f00a4e501d54771972065d8e9643a Mon Sep 17 00:00:00 2001 From: nikozer Date: Tue, 6 May 2025 20:44:07 +0300 Subject: [PATCH] fix unboxLower primitive conversion for bitwise Signed-off-by: nikozer --- ets2panda/compiler/lowering/ets/unboxLowering.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ets2panda/compiler/lowering/ets/unboxLowering.cpp b/ets2panda/compiler/lowering/ets/unboxLowering.cpp index a2b945c3c..29e8d1f37 100644 --- a/ets2panda/compiler/lowering/ets/unboxLowering.cpp +++ b/ets2panda/compiler/lowering/ets/unboxLowering.cpp @@ -518,6 +518,19 @@ static ir::Expression *InsertPrimitiveConversionIfNeeded(UnboxContext *uctx, ir: relation->IsSupertypeOf(expectedType, checker->GlobalCharBuiltinType())) { toConvert = uctx->checker->GlobalCharBuiltinType(); } + + // Appears in "~b" if "b" is of type Float + if (toConvert == nullptr && actualType->IsFloatType() && + relation->IsSupertypeOf(expectedType, checker->GlobalIntBuiltinType())) { + toConvert = checker->GlobalIntBuiltinType(); + } + + // Appears in "~b" if "b" is of type Double + if (toConvert == nullptr && actualType->IsDoubleType() && + relation->IsSupertypeOf(expectedType, checker->GlobalLongBuiltinType())) { + toConvert = checker->GlobalLongBuiltinType(); + } + ES2PANDA_ASSERT(toConvert != nullptr); auto *toConvertUnboxed = checker->MaybeUnboxType(toConvert); -- Gitee