[NI] Avoid type capturing for types that can contain type variables

This commit is contained in:
Mikhail Zarechenskiy
2017-08-17 14:36:56 +03:00
committed by Stanislav Erokhin
parent e040a317cc
commit 08964006de
7 changed files with 75 additions and 1 deletions
@@ -0,0 +1,14 @@
fun test(i: Inv<out Any?>) {
foo(i.superclass())
}
fun <T> foo(x: T) {}
class Inv<T>
fun <T> Inv<T>.superclass(): Inv<in T> = Inv()
fun box(): String {
test(Inv())
return "OK"
}
@@ -0,0 +1,10 @@
fun foo(useScriptArgs: Array<out Any?>?) {
val constructorArgs: Array<out Any?> = arrayOf(useScriptArgs.orEmpty())
}
inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()
fun box(): String {
foo(arrayOf(1))
return "OK"
}