JVM_IR: special case for raw types in DescriptorMangleComputer

This commit is contained in:
Georgy Bronnikov
2021-09-11 22:34:25 +03:00
committed by teamcityserver
parent 247cbffbac
commit 64e2911b58
2 changed files with 16 additions and 10 deletions
@@ -206,7 +206,7 @@ abstract class DescriptorMangleComputer(protected val builder: StringBuilder, pr
val lower = type.lowerBound
val lowerDescriptor = lower.constructor.declarationDescriptor as? ClassDescriptor
?: error("No class descriptor for lower type $lower of $type")
val intermediate = if (lowerDescriptor == upperDescriptor) {
val intermediate = if (lowerDescriptor == upperDescriptor && type !is RawType) {
lower.replace(newArguments = upper.arguments)
} else lower
val mixed = intermediate.makeNullableAsSpecified(upper.isMarkedNullable)
@@ -1,16 +1,22 @@
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FILE: UseRawType.java
import java.util.List;
// FILE: C.java
public class C<T> {
T val;
public class UseRawType {
static public List useList(List arg) {
return arg;
}
public C(T val) { this.val = val; }
public T getVal() { return val; }
}
// FILE: use.kt
inline fun callRawType() = UseRawType.useList(listOf("OK")) as List<String>
// FILE: UseRaw.java
public class UseRaw {
static public C cId(C c) { return c; }
static public void cId() {} // DescriptorByIdSignatureFinder only checks ID if there are multiple functions with a given name.
}
// FILE: inlineCall.kt
inline fun inlineCallRaw(s: String): String =
(UseRaw.cId(C(s)) as C<String>).getVal()
// FILE: box.kt
fun box() = callRawType()[0]
fun box() = inlineCallRaw("OK")