diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index 773400b32db..d72d53dc740 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -672,8 +672,8 @@ public abstract class StackValue { box(fromType, toType, v); } } - else if (fromType.getSort() == Type.OBJECT) { - //toType is primitive here + else if (fromType.getSort() == Type.OBJECT || fromType.getSort() == Type.ARRAY) { + // here toType is primitive and fromType is reference (object or array) Type unboxedType = unboxPrimitiveTypeOrNull(fromType); if (unboxedType != null) { unbox(fromType, unboxedType, v); diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index daf73834832..bf8eb94be8a 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -20795,6 +20795,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 26a7fbbaf15..d525bb4b723 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -420,8 +420,11 @@ class ExpressionCodegen( visitStatementContainer(expression, data) override fun visitCall(expression: IrCall, data: BlockInfo): PromisedValue { - classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol) - ?.invoke(expression, this, data)?.let { return it } + val intrinsic = classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol) + if (intrinsic != null) { + intrinsic.invoke(expression, this, data) + ?.let { return it } + } val callee = expression.symbol.owner require(callee.parent is IrClass) { "Unhandled intrinsic in ExpressionCodegen: ${callee.render()}" } diff --git a/compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt b/compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt new file mode 100644 index 00000000000..31954d73b8a --- /dev/null +++ b/compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME + +fun box(): String { + return if (run { 123 != intArrayOf() as Any }) "OK" else "Fail" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index b6534f4bc81..4beca574135 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -22566,6 +22566,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d0abf9223c2..049c177a7e4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -22566,6 +22566,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index cdc910a9b09..dfea3f7857f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -20795,6 +20795,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 1703e540fad..1fbe2b63019 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -17101,6 +17101,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index b0b98c267bb..e848fe808bf 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -17101,6 +17101,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 8bb37096b37..f89079338a6 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -17206,6 +17206,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 3c133b10458..262208530e7 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -10647,6 +10647,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/intEqualsNullableIntWithSmartCasts.kt"); } + @TestMetadata("kt42281.kt") + public void testKt42281() throws Exception { + runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/kt42281.kt"); + } + @TestMetadata("objectWithAsymmetricEqualsEqPrimitive.kt") public void testObjectWithAsymmetricEqualsEqPrimitive() throws Exception { runTest("compiler/testData/codegen/box/primitiveTypes/equalityWithObject/objectWithAsymmetricEqualsEqPrimitive.kt");