Report NON_VARARG_SPREAD on missed cases

^KT-48162 Fixed
This commit is contained in:
Victor Petukhov
2021-09-28 17:50:24 +03:00
parent 71ceffefb5
commit d9c50f0fda
14 changed files with 110 additions and 15 deletions
@@ -31,7 +31,7 @@ fun getArr(): Array<String>? = null
fun f() {
A().foo(1, <!SPREAD_OF_NULLABLE!>*<!>args)
bar(2, <!SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>args<!>)
baz(<!NON_VARARG_SPREAD, SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>args<!>)
baz(<!NON_VARARG_SPREAD_ERROR, SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>args<!>)
}
fun g(args: Array<String>?) {
@@ -55,7 +55,7 @@ fun h(b: B) {
fun k() {
A().foo(1, <!SPREAD_OF_NULLABLE!>*<!>getArr())
bar(2, <!SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>getArr()<!>)
baz(<!NON_VARARG_SPREAD, SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>getArr()<!>)
baz(<!NON_VARARG_SPREAD_ERROR, SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>getArr()<!>)
}
fun invokeTest(goodArgs: Array<String>) {
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNCHECKED_CAST
fun <T> Collection<T>.toArray(): Array<T> = this as Array<T>
fun Collection<String>.toArray2(): Array<String> = this as Array<String>
fun <T> toArray3(x: Collection<T>): Array<T> = x as Array<T>
class Foo<T> {
operator fun plus(x: Foo<T>): Array<T> {
return this + x
}
}
fun use(arg: Array<String>, s: Collection<String>, x: Foo<String>) {
arr(<!NON_VARARG_SPREAD!>*<!>arg)
arr(<!NON_VARARG_SPREAD!>*<!>s.toArray())
arr(<!NON_VARARG_SPREAD!>*<!>s.toArray2())
arr(<!NON_VARARG_SPREAD!>*<!>toArray3(s))
arr(<!NON_VARARG_SPREAD!>*<!>x + x)
arr(<!NON_VARARG_SPREAD!>*<!>(x + x))
}
fun arr(x: Array<String>) {}
+22
View File
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNCHECKED_CAST
fun <T> Collection<T>.toArray(): Array<T> = this as Array<T>
fun Collection<String>.toArray2(): Array<String> = this as Array<String>
fun <T> toArray3(x: Collection<T>): Array<T> = x as Array<T>
class Foo<T> {
operator fun plus(x: Foo<T>): Array<T> {
return this + x
}
}
fun use(arg: Array<String>, s: Collection<String>, x: Foo<String>) {
arr(<!NON_VARARG_SPREAD_ERROR!>*<!>arg)
arr(<!NON_VARARG_SPREAD_WARNING!>*<!>s.toArray())
arr(<!NON_VARARG_SPREAD_ERROR!>*<!>s.toArray2())
arr(<!NON_VARARG_SPREAD_WARNING!>*<!>toArray3(s))
arr(<!NON_VARARG_SPREAD_ERROR!>*<!>x + x)
arr(<!NON_VARARG_SPREAD_ERROR!>*<!>(x + x))
}
fun arr(x: Array<String>) {}
+16
View File
@@ -0,0 +1,16 @@
package
public fun arr(/*0*/ x: kotlin.Array<kotlin.String>): kotlin.Unit
public fun </*0*/ T> toArray3(/*0*/ x: kotlin.collections.Collection<T>): kotlin.Array<T>
public fun use(/*0*/ arg: kotlin.Array<kotlin.String>, /*1*/ s: kotlin.collections.Collection<kotlin.String>, /*2*/ x: Foo<kotlin.String>): kotlin.Unit
public fun </*0*/ T> kotlin.collections.Collection<T>.toArray(): kotlin.Array<T>
public fun kotlin.collections.Collection<kotlin.String>.toArray2(): kotlin.Array<kotlin.String>
public final class Foo</*0*/ T> {
public constructor Foo</*0*/ T>()
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 final operator fun plus(/*0*/ x: Foo<T>): kotlin.Array<T>
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}