Files
kotlin-fork/compiler/testData/codegen/box/reflection/genericSignature/defaultImplsGenericSignature.kt
T
Kristoffer Andersen 4dd794c2d2 [JVM_IR] Propagate Type Parameters to DefaultImpls
This ensures correct generation of generic signatures in the resulting
byte code, but it _is_ a work in progress: the actual type *arguments*
passed for these parameters during compilation are dummy `Any?` types.

Sites that need more work are indicated with TODO's.

- copy type parameters of interfaces to methods moved to DefaultImpls
- implement type parameter renaming scheme from JVM, with proper
  renaming and substitution.
- adjust call sites in bridges in classes->DefaultImpls
- adjust call sites in bridges from DefaultImpls->Interface
- adjust call sites in bridges from DefaultImpls->DefaultImpls
- adjust super calls ->DefaultImpls
- adjust calls in code of Interfaces->DefaultImpls
2020-02-04 17:41:31 +03:00

48 lines
908 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// FILE: J.java
public class J {
public static int test1() {
A<String, B<String>> x = new X<String, B<String>>("O", new B<String>("K"));
return A.DefaultImpls.test1(x, 1, 1.0);
}
public static A<String, B<String>> test2(){
X<String, B<String>> x = new X<String, B<String>>("O", new B<String>("K"));
return A.DefaultImpls.test2(x, 1);
}
}
// FILE: K.kt
class B<T>(val value: T)
interface A<T, Y : B<T>> {
fun <T, L> test1(p: T, z: L): T {
return p
}
fun <L> test2(p: L): A<T, Y> {
return this
}
}
class X<T, Y : B<T>>(val p1: T, val p2: Y) : A<T, Y> {
}
fun box(): String {
val test1 = J.test1()
if (test1 != 1) return "fail 1: $test1 != 1"
val test2: X<String, B<String>> = J.test2() as X<String, B<String>>
return test2.p1 + test2.p2.value
}