make FunctionCodegen skip method bodies we don't need, which avoids problems with inlining methods inside methods we don't need
KT-33604
This commit is contained in:
committed by
Alexey Tsvetkov
parent
b10f47b50e
commit
0285b26e40
@@ -452,7 +452,9 @@ public class FunctionCodegen {
|
|||||||
boolean staticInCompanionObject
|
boolean staticInCompanionObject
|
||||||
) {
|
) {
|
||||||
OwnerKind contextKind = methodContext.getContextKind();
|
OwnerKind contextKind = methodContext.getContextKind();
|
||||||
if (!state.getClassBuilderMode().generateBodies || isAbstractMethod(functionDescriptor, contextKind)) {
|
if (!state.getClassBuilderMode().generateBodies ||
|
||||||
|
isAbstractMethod(functionDescriptor, contextKind) ||
|
||||||
|
(state.getClassBuilderMode() == ClassBuilderMode.ABI && !InlineUtil.isInlineOrContainingInline(origin.getDescriptor()))) {
|
||||||
generateLocalVariableTable(
|
generateLocalVariableTable(
|
||||||
mv,
|
mv,
|
||||||
jvmSignature,
|
jvmSignature,
|
||||||
|
|||||||
Generated
+5
@@ -48,6 +48,11 @@ public class CompileAgainstJvmAbiTestGenerated extends AbstractCompileAgainstJvm
|
|||||||
runTest("plugins/jvm-abi-gen/testData/compile/inlineAnonymousObject/");
|
runTest("plugins/jvm-abi-gen/testData/compile/inlineAnonymousObject/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineCapture")
|
||||||
|
public void testInlineCapture() throws Exception {
|
||||||
|
runTest("plugins/jvm-abi-gen/testData/compile/inlineCapture/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlineReifiedFunction")
|
@TestMetadata("inlineReifiedFunction")
|
||||||
public void testInlineReifiedFunction() throws Exception {
|
public void testInlineReifiedFunction() throws Exception {
|
||||||
runTest("plugins/jvm-abi-gen/testData/compile/inlineReifiedFunction/");
|
runTest("plugins/jvm-abi-gen/testData/compile/inlineReifiedFunction/");
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import lib.*
|
||||||
|
|
||||||
|
fun runAppAndReturnOk(): String {
|
||||||
|
return inlineCapture("OK")
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package lib
|
||||||
|
|
||||||
|
fun inlineCapture(s: String): String {
|
||||||
|
return with(StringBuilder()) {
|
||||||
|
val o = object {
|
||||||
|
override fun toString() = s
|
||||||
|
}
|
||||||
|
append(o)
|
||||||
|
}.toString()
|
||||||
|
}
|
||||||
@@ -29,24 +29,8 @@ final class test/Class$NestedInnerClass {
|
|||||||
public method <init>(): void
|
public method <init>(): void
|
||||||
}
|
}
|
||||||
@kotlin.Metadata
|
@kotlin.Metadata
|
||||||
final class test/Class$classPublicMethod$publicMethodLambda$1 {
|
|
||||||
public final static field INSTANCE: test.Class$classPublicMethod$publicMethodLambda$1
|
|
||||||
inner class test/Class$classPublicMethod$publicMethodLambda$1
|
|
||||||
method <init>(): void
|
|
||||||
public final method invoke(p0: int): int
|
|
||||||
public synthetic method invoke(p0: java.lang.Object): java.lang.Object
|
|
||||||
}
|
|
||||||
@kotlin.Metadata
|
|
||||||
public final class test/Class$classPublicMethod$publicMethodLocalClass {
|
|
||||||
inner class test/Class$classPublicMethod$publicMethodLocalClass
|
|
||||||
public method <init>(): void
|
|
||||||
public final method getX(): int
|
|
||||||
}
|
|
||||||
@kotlin.Metadata
|
|
||||||
public final class test/Class {
|
public final class test/Class {
|
||||||
inner class test/Class$NestedInnerClass
|
inner class test/Class$NestedInnerClass
|
||||||
inner class test/Class$classPublicMethod$publicMethodLambda$1
|
|
||||||
inner class test/Class$classPublicMethod$publicMethodLocalClass
|
|
||||||
public method <init>(): void
|
public method <init>(): void
|
||||||
public final method classPublicMethod(): void
|
public final method classPublicMethod(): void
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user