JVM_IR KT-50856 fix generic signature for SAM proxy function
This commit is contained in:
+6
@@ -23517,6 +23517,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/kt49613.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50856.kt")
|
||||
public void testKt50856() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/kt50856.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction1.kt")
|
||||
public void testLocalFunction1() throws Exception {
|
||||
|
||||
+2
-1
@@ -335,7 +335,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
|
||||
val proxyFun = context.irFactory.buildFun {
|
||||
name = Name.identifier("${targetFun.name.asString()}__proxy")
|
||||
returnType = targetFun.returnType
|
||||
returnType = targetFun.returnType.eraseTypeParameters()
|
||||
visibility = DescriptorVisibilities.LOCAL
|
||||
modality = Modality.FINAL
|
||||
isSuspend = false
|
||||
@@ -372,6 +372,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
updateFrom(originalParameter)
|
||||
name = Name.identifier("p$proxyParameterIndex\$${originalParameter.name.asString()}")
|
||||
index = proxyParameterIndex
|
||||
type = originalParameter.type.eraseTypeParameters()
|
||||
proxyParameterIndex++
|
||||
}.apply {
|
||||
parent = proxyFun
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_STDLIB
|
||||
// FILE: box.kt
|
||||
fun <U> get(x: Sam<U>): U =
|
||||
x.get()
|
||||
|
||||
fun test() {
|
||||
get<Map<String, String>>(::mutableMapOf)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam<T> {
|
||||
T get();
|
||||
|
||||
static void run() {
|
||||
BoxKt.test();
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -1,4 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// WITH_SIGNATURES
|
||||
// WITH_STDLIB
|
||||
|
||||
// FILE: indySamConversionViaProxyFun.kt.kt
|
||||
inline fun ifn() {}
|
||||
@@ -14,10 +16,15 @@ fun test() {
|
||||
|
||||
// Proxy function for arrayOf fun should be non-synthetic
|
||||
use(Sam3(::intArrayOf))
|
||||
|
||||
// Proxy function for generic fun should have valid generic signature
|
||||
use4<Map<String, String>>(::mutableMapOf)
|
||||
}
|
||||
|
||||
fun use(x: Any) {}
|
||||
|
||||
fun <U> use4(x: Sam4<U>) {}
|
||||
|
||||
// FILE: Sam1.java
|
||||
public interface Sam1 {
|
||||
String get(String x, Object y);
|
||||
@@ -31,4 +38,9 @@ public interface Sam2 {
|
||||
// FILE: Sam3.java
|
||||
public interface Sam3 {
|
||||
int[] get(int[] s);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Sam4.java
|
||||
public interface Sam4<T> {
|
||||
T get();
|
||||
}
|
||||
|
||||
+11
-9
@@ -1,12 +1,14 @@
|
||||
@kotlin.Metadata
|
||||
public final class IndySamConversionViaProxyFun_ktKt {
|
||||
public final class<null> IndySamConversionViaProxyFun_ktKt {
|
||||
// source: 'indySamConversionViaProxyFun.kt.kt'
|
||||
public final static method ifn(): void
|
||||
private final static method test$ifn__proxy(): void
|
||||
private varargs final static method test$intArrayOf__proxy(p0: int[]): int[]
|
||||
private synthetic final static method test$plus__proxy(p0: java.lang.String, p1: java.lang.Object): java.lang.String
|
||||
private synthetic final static method test$plus__proxy-0(p0: java.lang.String, p1: java.lang.Object): java.lang.String
|
||||
private synthetic final static method test$plus__proxy-1(p0: java.lang.String, p1: java.lang.Object): java.lang.String
|
||||
public final static method test(): void
|
||||
public final static method use(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void
|
||||
private final static <()Ljava/util/Map<Ljava/lang/Object;Ljava/lang/Object;>;> method test$mutableMapOf__proxy(): java.util.Map
|
||||
public final static <<U:Ljava/lang/Object;>(LSam4<TU;>;)V> method use4(@org.jetbrains.annotations.NotNull p0: Sam4): void
|
||||
public final static <null> method ifn(): void
|
||||
private final static <null> method test$ifn__proxy(): void
|
||||
private varargs final static <null> method test$intArrayOf__proxy(p0: int[]): int[]
|
||||
private synthetic final static <null> method test$plus__proxy(p0: java.lang.String, p1: java.lang.Object): java.lang.String
|
||||
private synthetic final static <null> method test$plus__proxy-0(p0: java.lang.String, p1: java.lang.Object): java.lang.String
|
||||
private synthetic final static <null> method test$plus__proxy-1(p0: java.lang.String, p1: java.lang.Object): java.lang.String
|
||||
public final static <null> method test(): void
|
||||
public final static <null> method use(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void
|
||||
}
|
||||
|
||||
+6
@@ -23517,6 +23517,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/kt49613.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50856.kt")
|
||||
public void testKt50856() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/kt50856.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction1.kt")
|
||||
public void testLocalFunction1() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user