NI: use the inferred type to check of nullable array for vararg

^KT-40555 Fixed
This commit is contained in:
Victor Petukhov
2020-07-27 13:03:45 +03:00
parent 9d63412b3e
commit cca64b8fab
7 changed files with 72 additions and 5 deletions
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: Test.java
public class Test {
static public void foo(String ... x) {
}
}
// FILE: test.kt
fun <T> select(vararg x: T) = x[1]
fun main(x: Array<String>?) {
Test.foo(*(select(arrayOf(""), null))) // no compilation errors before the fix, NPE
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: Test.java
public class Test {
static public void foo(String ... x) {
}
}
// FILE: test.kt
fun <T> select(vararg x: T) = x[1]
fun main(x: Array<String>?) {
Test.foo(<!SPREAD_OF_NULLABLE!>*<!>(select(arrayOf(""), null))) // no compilation errors before the fix, NPE
}
@@ -0,0 +1,14 @@
package
public fun main(/*0*/ x: kotlin.Array<kotlin.String>?): kotlin.Unit
public fun </*0*/ T> select(/*0*/ vararg x: T /*kotlin.Array<out T>*/): T
public open class Test {
public constructor Test()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public open fun foo(/*0*/ vararg x: kotlin.String! /*kotlin.Array<(out) kotlin.String!>!*/): kotlin.Unit
}