IR: copy type parameters for local functions in LocalDeclarationLowering

Local functions raised in LocalDeclarationLowering continue to refer to
type parameters that are no longer visible to them.
This commit only adds new type parameters to their declarations, which
makes JVM accept those declarations. The generated IR is still
semantically incorrect (needs further fix), but code generation seems
to proceed nevertheless.
This commit is contained in:
Georgy Bronnikov
2019-12-24 18:25:57 +03:00
parent 01da7f289b
commit 8d0ffa1444
9 changed files with 220 additions and 35 deletions
@@ -0,0 +1,7 @@
package test;
class TypeParamInInner {
void check() {
TypeParamInInnerKt.outer("OK");
}
}
@@ -0,0 +1,31 @@
package test
class outerClass<T>(val t: T) {
inner class innerClass {
fun getT() = t
}
}
fun <T> outer(arg: T): T {
class localClass(val v: T) {
init {
fun innerFunInLocalClass() = v
val vv = innerFunInLocalClass()
}
fun member() = v
}
fun innerFun(): T {
class localClassInLocalFunction {
val v = arg
}
return localClass(arg).member()
}
fun <X> innerFunWithOwnTypeParam(x: X) = x
innerFunWithOwnTypeParam(arg)
return innerFun()
}
@@ -0,0 +1,18 @@
package test
public fun </*0*/ T> outer(/*0*/ T): T
public/*package*/ open class TypeParamInInner {
public/*package*/ constructor TypeParamInInner()
public/*package*/ open fun check(): kotlin.Unit
}
public final class outerClass</*0*/ T> {
public constructor outerClass</*0*/ T>(/*0*/ T)
public final val t: T
public final inner class innerClass /*captured type parameters: /*0*/ T*/ {
public constructor innerClass()
public final fun getT(): T
}
}