KT-53146 Don't coerce Nothing? returned from "catch" clauses
At first, I tried to modify the logic in PromisedValue.materializeAt to get rid of all casts from Nothing? to other types, but that broke a number of tests containing casts of java.lang.Void to other types, so I decided to fix only this particular case with try...catch (for some reason, here we get a null of type java.lang.Object).
This commit is contained in:
committed by
teamcity
parent
4baa74f396
commit
903a5d69a4
+6
@@ -4781,6 +4781,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/casts/kt50577.kt");
|
runTest("compiler/testData/codegen/box/casts/kt50577.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt53146.kt")
|
||||||
|
public void testKt53146() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/casts/kt53146.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt53677.kt")
|
@TestMetadata("kt53677.kt")
|
||||||
public void testKt53677() throws Exception {
|
public void testKt53677() throws Exception {
|
||||||
|
|||||||
+3
-1
@@ -1225,7 +1225,9 @@ class ExpressionCodegen(
|
|||||||
|
|
||||||
val catchResult = catchBody.accept(this, catchBlockInfo)
|
val catchResult = catchBody.accept(this, catchBlockInfo)
|
||||||
if (savedValue != null) {
|
if (savedValue != null) {
|
||||||
catchResult.materializeAt(tryAsmType, aTry.type, true)
|
if (catchResult.irType != context.irBuiltIns.nothingNType) {
|
||||||
|
catchResult.materializeAt(tryAsmType, aTry.type, true)
|
||||||
|
}
|
||||||
mv.store(savedValue, tryAsmType)
|
mv.store(savedValue, tryAsmType)
|
||||||
} else {
|
} else {
|
||||||
catchResult.discard()
|
catchResult.discard()
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// WITH_STDLIB
|
||||||
|
// FULL_JDK
|
||||||
|
// CHECK_BYTECODE_TEXT
|
||||||
|
|
||||||
|
class A
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a = try {
|
||||||
|
A()
|
||||||
|
} catch (e: NoClassDefFoundError) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 0 CHECKCAST
|
||||||
+6
@@ -4781,6 +4781,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/casts/kt50577.kt");
|
runTest("compiler/testData/codegen/box/casts/kt50577.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt53146.kt")
|
||||||
|
public void testKt53146() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/casts/kt53146.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt53677.kt")
|
@TestMetadata("kt53677.kt")
|
||||||
public void testKt53677() throws Exception {
|
public void testKt53677() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user