Fix for KT-8948: CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'foo' into
#KT-8948 Fixed
This commit is contained in:
+3
-4
@@ -143,7 +143,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
|
||||
|
||||
AbstractInsnNode markedReturn = curIns;
|
||||
AbstractInsnNode instrInsertFinallyBefore = markedReturn.getPrevious();
|
||||
AbstractInsnNode nextPrev = instrInsertFinallyBefore.getPrevious().getPrevious();
|
||||
AbstractInsnNode nextPrev = instrInsertFinallyBefore.getPrevious();
|
||||
assert markedReturn.getNext() instanceof LabelNode : "Label should be occurred after non-local return";
|
||||
LabelNode newFinallyEnd = (LabelNode) markedReturn.getNext();
|
||||
Type nonLocalReturnType = InlineCodegenUtil.getReturnType(markedReturn.getOpcode());
|
||||
@@ -166,6 +166,8 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
|
||||
List<TryCatchBlockNodeInfo> clusterBlocks = clusterToFindFinally.getBlocks();
|
||||
TryCatchBlockNodeInfo nodeWithDefaultHandlerIfExists = clusterBlocks.get(clusterBlocks.size() - 1);
|
||||
|
||||
FinallyBlockInfo finallyInfo = findFinallyBlockBody(nodeWithDefaultHandlerIfExists, getTryBlocksMetaInfo().getAllIntervals());
|
||||
if (finallyInfo == null) continue;
|
||||
|
||||
if (nodeWithDefaultHandlerIfExists.getOnlyCopyNotProcess()) {
|
||||
//lambdas finally generated before non-local return instruction,
|
||||
@@ -173,9 +175,6 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
|
||||
throw new RuntimeException("Lambda try blocks should be skipped");
|
||||
}
|
||||
|
||||
FinallyBlockInfo finallyInfo = findFinallyBlockBody(nodeWithDefaultHandlerIfExists, getTryBlocksMetaInfo().getAllIntervals());
|
||||
if (finallyInfo == null) continue;
|
||||
|
||||
originalDepthIndex++;
|
||||
|
||||
instructions.resetLabels();
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
foo {
|
||||
try {
|
||||
return "OK"
|
||||
} catch(e: Exception) {
|
||||
return "fail 1"
|
||||
}
|
||||
}
|
||||
|
||||
return "fail 2"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
inline fun foo(f: () -> Unit) {
|
||||
try {
|
||||
f()
|
||||
}
|
||||
finally {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import test.*
|
||||
|
||||
var p = "fail"
|
||||
|
||||
fun test() {
|
||||
foo {
|
||||
try {
|
||||
p = "O"
|
||||
return
|
||||
} catch(e: Exception) {
|
||||
return
|
||||
} finally {
|
||||
p += "K"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test()
|
||||
return p
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
inline fun foo(f: () -> Unit) {
|
||||
try {
|
||||
f()
|
||||
}
|
||||
finally {
|
||||
1
|
||||
}
|
||||
}
|
||||
+12
@@ -481,6 +481,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt8948.1.kt")
|
||||
public void testKt8948() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/kt8948.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt8948v2.1.kt")
|
||||
public void testKt8948v2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/kt8948v2.1.kt");
|
||||
doTestMultiFileWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedNonLocals.1.kt")
|
||||
public void testNestedNonLocals() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/nestedNonLocals.1.kt");
|
||||
|
||||
+12
@@ -481,6 +481,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt8948.1.kt")
|
||||
public void testKt8948() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/kt8948.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt8948v2.1.kt")
|
||||
public void testKt8948v2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/kt8948v2.1.kt");
|
||||
doBoxTestWithInlineCheck(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedNonLocals.1.kt")
|
||||
public void testNestedNonLocals() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/nonLocalReturns/nestedNonLocals.1.kt");
|
||||
|
||||
Reference in New Issue
Block a user