Write additional type parameters for DefaultImpls methods, fix for KT-11121: BadClassFile exception for interface implemented generic properties
#KT-11121 Fixed
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
// 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
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
class B<M>
|
||||
|
||||
interface A<T, Y : B<T>> {
|
||||
|
||||
fun <T, L> p(p: T): T {
|
||||
return p
|
||||
}
|
||||
|
||||
val <T> T.z : T?
|
||||
get() = null
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val defaultImpls = Class.forName("A\$DefaultImpls")
|
||||
val declaredMethod = defaultImpls.getDeclaredMethod("p", A::class.java, Any::class.java)
|
||||
if (declaredMethod.toGenericString() != "public static <T_I1,Y,T,L> T A\$DefaultImpls.p(A<T_I1, Y>,T)") return "fail 1: ${declaredMethod.toGenericString()}"
|
||||
|
||||
val declaredProperty = defaultImpls.getDeclaredMethod("getZ", A::class.java, Any::class.java)
|
||||
if (declaredProperty.toGenericString() != "public static <T_I1,Y,T> T A\$DefaultImpls.getZ(A<T_I1, Y>,T)") return "fail 2: ${declaredProperty.toGenericString()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user