NI: use the inferred type to check of nullable array for vararg
^KT-40555 Fixed
This commit is contained in:
+15
@@ -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
|
||||
}
|
||||
+14
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user