JVM_IR Do not generate generic signatures for lifted lambda methods
This commit is contained in:
committed by
TeamCityServer
parent
00a335129b
commit
737fbe271f
+12
@@ -19945,6 +19945,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/extensionLambda.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/extensionLambda.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void testGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaSerializable.kt")
|
@TestMetadata("lambdaSerializable.kt")
|
||||||
public void testLambdaSerializable() throws Exception {
|
public void testLambdaSerializable() throws Exception {
|
||||||
@@ -20127,6 +20133,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void testGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intReturnTypeAsNumber.kt")
|
@TestMetadata("intReturnTypeAsNumber.kt")
|
||||||
public void testIntReturnTypeAsNumber() throws Exception {
|
public void testIntReturnTypeAsNumber() throws Exception {
|
||||||
|
|||||||
+6
-2
@@ -57,17 +57,21 @@ class FunctionCodegen(
|
|||||||
private fun doGenerate(): SMAPAndMethodNode {
|
private fun doGenerate(): SMAPAndMethodNode {
|
||||||
val signature = context.methodSignatureMapper.mapSignatureWithGeneric(irFunction)
|
val signature = context.methodSignatureMapper.mapSignatureWithGeneric(irFunction)
|
||||||
val flags = irFunction.calculateMethodFlags()
|
val flags = irFunction.calculateMethodFlags()
|
||||||
|
val isSynthetic = flags.and(Opcodes.ACC_SYNTHETIC) != 0
|
||||||
val methodNode = MethodNode(
|
val methodNode = MethodNode(
|
||||||
Opcodes.API_VERSION,
|
Opcodes.API_VERSION,
|
||||||
flags,
|
flags,
|
||||||
signature.asmMethod.name,
|
signature.asmMethod.name,
|
||||||
signature.asmMethod.descriptor,
|
signature.asmMethod.descriptor,
|
||||||
signature.genericsSignature.takeIf { flags.and(Opcodes.ACC_SYNTHETIC) == 0 },
|
signature.genericsSignature
|
||||||
|
.takeIf {
|
||||||
|
!isSynthetic && irFunction.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||||
|
},
|
||||||
getThrownExceptions(irFunction)?.toTypedArray()
|
getThrownExceptions(irFunction)?.toTypedArray()
|
||||||
)
|
)
|
||||||
val methodVisitor: MethodVisitor = wrapWithMaxLocalCalc(methodNode)
|
val methodVisitor: MethodVisitor = wrapWithMaxLocalCalc(methodNode)
|
||||||
|
|
||||||
if (context.state.generateParametersMetadata && flags.and(Opcodes.ACC_SYNTHETIC) == 0) {
|
if (context.state.generateParametersMetadata && !isSynthetic) {
|
||||||
generateParameterNames(irFunction, methodVisitor, signature, context.state)
|
generateParameterNames(irFunction, methodVisitor, signature, context.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+14
-22
@@ -2,36 +2,28 @@
|
|||||||
// WASM_MUTE_REASON: SAM_CONVERSIONS
|
// WASM_MUTE_REASON: SAM_CONVERSIONS
|
||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
fun <T> underlying(a: IC): T = bar(a) {
|
fun <T1> underlying(a: IC): T1 = bar(a) { it.value as T1 }
|
||||||
it.value as T
|
|
||||||
|
fun <T2> extension(a: IC): T2 = bar(a) { it.extensionValue() }
|
||||||
|
|
||||||
|
fun <T3> dispatch(a: IC): T3 = bar(a) { it.dispatchValue() }
|
||||||
|
|
||||||
|
fun <T4> normal(a: IC): T4 = bar(a) { normalValue(it) }
|
||||||
|
|
||||||
|
fun interface FunIFace<T0, R> {
|
||||||
|
fun call(ic: T0): R
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> extension(a: IC): T = bar(a) {
|
fun <T5, R> bar(value: T5, f: FunIFace<T5, R>): R {
|
||||||
it.extensionValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> dispatch(a: IC): T = bar(a) {
|
|
||||||
it.dispatchValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> normal(a: IC): T = bar(a) {
|
|
||||||
normalValue(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun interface FunIFace<T, R> {
|
|
||||||
fun call(ic: T): R
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T, R> bar(value: T, f: FunIFace<T, R>): R {
|
|
||||||
return f.call(value)
|
return f.call(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> IC.extensionValue(): T = value as T
|
fun <T6> IC.extensionValue(): T6 = value as T6
|
||||||
|
|
||||||
fun <T> normalValue(ic: IC): T = ic.value as T
|
fun <T7> normalValue(ic: IC): T7 = ic.value as T7
|
||||||
|
|
||||||
inline class IC(val value: Int) {
|
inline class IC(val value: Int) {
|
||||||
fun <T> dispatchValue(): T = value as T
|
fun <T8> dispatchValue(): T8 = value as T8
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
// LAMBDAS: INDY
|
||||||
|
// CHECK_BYTECODE_LISTING
|
||||||
|
// WITH_SIGNATURES
|
||||||
|
|
||||||
|
fun <T1, R> call(value: T1, f: (T1) -> R): R {
|
||||||
|
return f(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T2> test(x: T2) = call(x) { it }
|
||||||
|
|
||||||
|
fun box() = test("OK")
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class<null> GenericLambdaSignatureKt {
|
||||||
|
// source: 'genericLambdaSignature.kt'
|
||||||
|
public final static <<T1:Ljava/lang/Object;R:Ljava/lang/Object;>(TT1;Lkotlin/jvm/functions/Function1<-TT1;+TR;>;)TR;> method call(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.jvm.functions.Function1): java.lang.Object
|
||||||
|
public final static <<T2:Ljava/lang/Object;>(TT2;)TT2;> method test(p0: java.lang.Object): java.lang.Object
|
||||||
|
public final static @org.jetbrains.annotations.NotNull <null> method box(): java.lang.String
|
||||||
|
private final static <null> method test$lambda-0(p0: java.lang.Object): java.lang.Object
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
// SAM_CONVERSIONS: INDY
|
||||||
|
// CHECK_BYTECODE_LISTING
|
||||||
|
// WITH_SIGNATURES
|
||||||
|
|
||||||
|
fun interface FunIFace<T0, R> {
|
||||||
|
fun call(arg: T0): R
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T1, R> call(value: T1, f: FunIFace<T1, R>): R {
|
||||||
|
return f.call(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T2> test(x: T2) = call(x) { it }
|
||||||
|
|
||||||
|
fun box() = test("OK")
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public interface<<T0:Ljava/lang/Object;R:Ljava/lang/Object;>Ljava/lang/Object;> FunIFace {
|
||||||
|
// source: 'genericLambdaSignature.kt'
|
||||||
|
public abstract <(TT0;)TR;> method call(p0: java.lang.Object): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class<null> GenericLambdaSignatureKt {
|
||||||
|
// source: 'genericLambdaSignature.kt'
|
||||||
|
public final static <<T1:Ljava/lang/Object;R:Ljava/lang/Object;>(TT1;LFunIFace<TT1;TR;>;)TR;> method call(p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: FunIFace): java.lang.Object
|
||||||
|
public final static <<T2:Ljava/lang/Object;>(TT2;)TT2;> method test(p0: java.lang.Object): java.lang.Object
|
||||||
|
public final static @org.jetbrains.annotations.NotNull <null> method box(): java.lang.String
|
||||||
|
private final static <null> method test$lambda-0(p0: java.lang.Object): java.lang.Object
|
||||||
|
}
|
||||||
+12
@@ -19945,6 +19945,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/extensionLambda.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/extensionLambda.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void testGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaSerializable.kt")
|
@TestMetadata("lambdaSerializable.kt")
|
||||||
public void testLambdaSerializable() throws Exception {
|
public void testLambdaSerializable() throws Exception {
|
||||||
@@ -20127,6 +20133,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void testGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intReturnTypeAsNumber.kt")
|
@TestMetadata("intReturnTypeAsNumber.kt")
|
||||||
public void testIntReturnTypeAsNumber() throws Exception {
|
public void testIntReturnTypeAsNumber() throws Exception {
|
||||||
|
|||||||
+12
@@ -19945,6 +19945,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/extensionLambda.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/extensionLambda.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void testGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaSerializable.kt")
|
@TestMetadata("lambdaSerializable.kt")
|
||||||
public void testLambdaSerializable() throws Exception {
|
public void testLambdaSerializable() throws Exception {
|
||||||
@@ -20127,6 +20133,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void testGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("intReturnTypeAsNumber.kt")
|
@TestMetadata("intReturnTypeAsNumber.kt")
|
||||||
public void testIntReturnTypeAsNumber() throws Exception {
|
public void testIntReturnTypeAsNumber() throws Exception {
|
||||||
|
|||||||
+3
-2
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test.backend.handlers
|
|||||||
import org.jetbrains.kotlin.codegen.BytecodeListingTextCollectingVisitor
|
import org.jetbrains.kotlin.codegen.BytecodeListingTextCollectingVisitor
|
||||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.CHECK_BYTECODE_LISTING
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.CHECK_BYTECODE_LISTING
|
||||||
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.WITH_SIGNATURES
|
||||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||||
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
import org.jetbrains.kotlin.test.model.BinaryArtifacts
|
||||||
import org.jetbrains.kotlin.test.model.TestModule
|
import org.jetbrains.kotlin.test.model.TestModule
|
||||||
@@ -27,10 +28,10 @@ class BytecodeListingHandler(testServices: TestServices) : JvmBinaryArtifactHand
|
|||||||
if (CHECK_BYTECODE_LISTING !in module.directives) return
|
if (CHECK_BYTECODE_LISTING !in module.directives) return
|
||||||
val dump = BytecodeListingTextCollectingVisitor.getText(
|
val dump = BytecodeListingTextCollectingVisitor.getText(
|
||||||
info.classFileFactory,
|
info.classFileFactory,
|
||||||
BytecodeListingTextCollectingVisitor.Filter.ForCodegenTests
|
BytecodeListingTextCollectingVisitor.Filter.ForCodegenTests,
|
||||||
|
withSignatures = WITH_SIGNATURES in module.directives
|
||||||
)
|
)
|
||||||
multiModuleInfoDumper.builderForModule(module).append(dump)
|
multiModuleInfoDumper.builderForModule(module).append(dump)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
|
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
|
||||||
|
|||||||
+6
-1
@@ -48,7 +48,12 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val CHECK_BYTECODE_LISTING by directive(
|
val CHECK_BYTECODE_LISTING by directive(
|
||||||
description = "Dump resulting bytecode to .txt or _ir.txt file",
|
description = "Dump generated classes to .txt or _ir.txt file",
|
||||||
|
applicability = Global
|
||||||
|
)
|
||||||
|
|
||||||
|
val WITH_SIGNATURES by directive(
|
||||||
|
description = "Include generic signatures in generated classes dump",
|
||||||
applicability = Global
|
applicability = Global
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+10
@@ -16652,6 +16652,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/bigArityExtLambda.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/bigArityExtLambda.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void ignoreGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaSerializable.kt")
|
@TestMetadata("lambdaSerializable.kt")
|
||||||
public void ignoreLambdaSerializable() throws Exception {
|
public void ignoreLambdaSerializable() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/lambdaSerializable.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/lambdas/lambdaSerializable.kt");
|
||||||
@@ -16778,6 +16783,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class Sam extends AbstractLightAnalysisModeTest {
|
public static class Sam extends AbstractLightAnalysisModeTest {
|
||||||
|
@TestMetadata("genericLambdaSignature.kt")
|
||||||
|
public void ignoreGenericLambdaSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/genericLambdaSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendFunInterface.kt")
|
@TestMetadata("suspendFunInterface.kt")
|
||||||
public void ignoreSuspendFunInterface() throws Exception {
|
public void ignoreSuspendFunInterface() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt");
|
runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user