Fix for KT-11479: 1.0.2 Snapshot: CompilationException: Back-end (JVM) Internal error: Couldn't inline method call
#KT-11479 Fixed
This commit is contained in:
@@ -370,7 +370,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
MethodInliner inliner = new MethodInliner(
|
||||
node, parameters, info, new FieldRemapper(null, null, parameters), isSameModule,
|
||||
"Method inlining " + callElement.getText(),
|
||||
createNestedSourceMapper(nodeAndSmap), info.getCallSiteInfo(),
|
||||
createNestedSourceMapper(nodeAndSmap, sourceMapper), info.getCallSiteInfo(),
|
||||
AnnotationUtilKt.hasInlineOnlyAnnotation(functionDescriptor) ? new InlineOnlySmapSkipper(codegen) : null
|
||||
); //with captured
|
||||
|
||||
@@ -882,8 +882,8 @@ public class InlineCodegen extends CallGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private SourceMapper createNestedSourceMapper(@NotNull SMAPAndMethodNode nodeAndSmap) {
|
||||
return new NestedSourceMapper(sourceMapper, nodeAndSmap.getRanges(), nodeAndSmap.getClassSMAP().getSourceInfo());
|
||||
public static SourceMapper createNestedSourceMapper(@NotNull SMAPAndMethodNode nodeAndSmap, @NotNull SourceMapper parent) {
|
||||
return new NestedSourceMapper(parent, nodeAndSmap.getRanges(), nodeAndSmap.getClassSMAP().getSourceInfo());
|
||||
}
|
||||
|
||||
static void reportIncrementalInfo(
|
||||
|
||||
+16
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
|
||||
class InlineCodegenForDefaultBody(
|
||||
function: FunctionDescriptor,
|
||||
@@ -34,6 +35,8 @@ class InlineCodegenForDefaultBody(
|
||||
val state: GenerationState
|
||||
) : CallGenerator() {
|
||||
|
||||
private val sourceMapper: SourceMapper = codegen.parentCodegen.orCreateSourceMapper
|
||||
|
||||
private val functionDescriptor =
|
||||
if (InlineUtil.isArrayConstructorWithLambda(function))
|
||||
FictitiousArrayConstructor.create(function as ConstructorDescriptor)
|
||||
@@ -57,7 +60,19 @@ class InlineCodegenForDefaultBody(
|
||||
|
||||
override fun genCallInner(callableMethod: Callable, resolvedCall: ResolvedCall<*>?, callDefault: Boolean, codegen: ExpressionCodegen) {
|
||||
val nodeAndSmap = InlineCodegen.createMethodNode(functionDescriptor, jvmSignature, codegen, context, callDefault, state)
|
||||
nodeAndSmap.node.accept(MethodBodyVisitor(codegen.v))
|
||||
val childSourceMapper = InlineCodegen.createNestedSourceMapper(nodeAndSmap, sourceMapper)
|
||||
|
||||
val node = nodeAndSmap.node
|
||||
val transformedMethod = MethodNode(
|
||||
node.access,
|
||||
node.name,
|
||||
node.desc,
|
||||
node.signature,
|
||||
node.exceptions.toTypedArray())
|
||||
|
||||
node.accept(InlineAdapter(transformedMethod, 0, childSourceMapper))
|
||||
|
||||
transformedMethod.accept(MethodBodyVisitor(codegen.v))
|
||||
}
|
||||
|
||||
override fun afterParameterPut(type: Type, stackValue: StackValue?, parameterIndex: Int) {
|
||||
|
||||
@@ -29,15 +29,15 @@ class SMAPAndMethodNode(val node: MethodNode, val classSMAP: SMAP) {
|
||||
}
|
||||
|
||||
private fun createLineNumberSequence(node: MethodNode, classSMAP: SMAP): Sequence<LabelAndMapping> {
|
||||
return InsnSequence(node.instructions.first, null).filterIsInstance<LineNumberNode>().map { node ->
|
||||
val index = classSMAP.intervals.binarySearch(RangeMapping(node.line, node.line, 1), Comparator {
|
||||
return InsnSequence(node.instructions.first, null).filterIsInstance<LineNumberNode>().map { lineNumber ->
|
||||
val index = classSMAP.intervals.binarySearch(RangeMapping(lineNumber.line, lineNumber.line, 1), Comparator {
|
||||
value, key ->
|
||||
if (key.dest in value) 0 else RangeMapping.Comparator.compare(value, key)
|
||||
})
|
||||
if (index < 0) {
|
||||
error("Unmapped label in inlined function $node ${node.line}")
|
||||
error("Unmapped label in inlined function $node ${lineNumber.line}")
|
||||
}
|
||||
LabelAndMapping(node, classSMAP.intervals[index])
|
||||
LabelAndMapping(lineNumber, classSMAP.intervals[index])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user