diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java index a27919f5e20..53f2d0d70bb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java @@ -660,13 +660,15 @@ public class AsmUtil { @Override public void putSelector(@NotNull Type type, @NotNull InstructionAdapter v) { - stackValue.put(type, v); - if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { + Type innerType = stackValue.type; + stackValue.put(innerType, v); + if (innerType.getSort() == Type.OBJECT || innerType.getSort() == Type.ARRAY) { v.dup(); v.visitLdcInsn(runtimeAssertionInfo.getMessage()); v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V", false); } + StackValue.coerce(innerType, type, v); } }; } diff --git a/compiler/testData/codegen/boxAgainstJava/platformTypes/kt14989.kt b/compiler/testData/codegen/boxAgainstJava/platformTypes/kt14989.kt new file mode 100644 index 00000000000..1f7ca2e9ac4 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/platformTypes/kt14989.kt @@ -0,0 +1,26 @@ +//WITH_RUNTIME +// FILE: JavaClass.java + +public class JavaClass { + + public Double test() { + return null; + } + +} + +// FILE: b.kt + +fun test(s: Double) { + +} + +fun box(): String { + try { + test(JavaClass().test()) + } + catch (e: IllegalStateException) { + return "OK" + } + return "fail" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java index 703425e05a2..7f441f558e1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -368,6 +368,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxAga doTest(fileName); } + @TestMetadata("kt14989.kt") + public void testKt14989() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/platformTypes/kt14989.kt"); + doTest(fileName); + } + @TestMetadata("specializedMapFull.kt") public void testSpecializedMapFull() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/platformTypes/specializedMapFull.kt");