Add NON_VARARG_SPREAD and SPREAD_OF_NULLABLE diagnostics to new inference

This commit is contained in:
Dmitriy Novozhilov
2019-01-17 15:28:27 +03:00
parent 622fd8d8cf
commit 7f48897e21
5 changed files with 89 additions and 6 deletions
@@ -10,6 +10,15 @@ public class A {
public static String[] ar;
}
// FILE: J.java
public class J {
public interface Invoke {
void invoke(String ...args);
}
public static Invoke staticFun;
}
// FILE: 1.kt
val args: Array<String>? = null
@@ -18,10 +27,12 @@ fun bar(x: Int, vararg s: String) {}
fun baz(s: String) {}
fun getArr(): Array<String>? = null
fun f() {
A().foo(1, <!OI;SPREAD_OF_NULLABLE!>*<!>args)
bar(2, <!OI;SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>args<!>)
baz(<!OI;SPREAD_OF_NULLABLE, NON_VARARG_SPREAD!>*<!><!NI;TYPE_MISMATCH!>args<!>)
A().foo(1, <!SPREAD_OF_NULLABLE!>*<!>args)
bar(2, <!SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>args<!>)
baz(<!NON_VARARG_SPREAD, SPREAD_OF_NULLABLE!>*<!><!NI;TYPE_MISMATCH!>args<!>)
}
fun g(args: Array<String>?) {
@@ -38,8 +49,17 @@ class B {
fun h(b: B) {
if (b.args != null) {
A().foo(1, <!OI;SPREAD_OF_NULLABLE!>*<!><!OI;SMARTCAST_IMPOSSIBLE!>b.args<!>)
A().foo(1, <!SPREAD_OF_NULLABLE!>*<!><!OI;SMARTCAST_IMPOSSIBLE!>b.args<!>)
}
}
fun k() {
A().foo(1, <!SPREAD_OF_NULLABLE!>*<!>getArr())
bar(2, <!SPREAD_OF_NULLABLE!>*<!><!TYPE_MISMATCH!>getArr()<!>)
baz(<!NON_VARARG_SPREAD, SPREAD_OF_NULLABLE!>*<!><!NI;TYPE_MISMATCH!>getArr()<!>)
}
fun invokeTest(goodArgs: Array<String>) {
J.staticFun(*goodArgs)
J.staticFun(<!SPREAD_OF_NULLABLE!>*<!>args)
}
@@ -5,7 +5,10 @@ public fun bar(/*0*/ x: kotlin.Int, /*1*/ vararg s: kotlin.String /*kotlin.Array
public fun baz(/*0*/ s: kotlin.String): kotlin.Unit
public fun f(): kotlin.Unit
public fun g(/*0*/ args: kotlin.Array<kotlin.String>?): kotlin.Unit
public fun getArr(): kotlin.Array<kotlin.String>?
public fun h(/*0*/ b: B): kotlin.Unit
public fun invokeTest(/*0*/ goodArgs: kotlin.Array<kotlin.String>): kotlin.Unit
public fun k(): kotlin.Unit
public open class A {
public constructor A()
@@ -25,3 +28,20 @@ public final class B {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class J {
public constructor J()
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
public interface Invoke {
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 abstract operator fun invoke(/*0*/ vararg args: kotlin.String! /*kotlin.Array<(out) kotlin.String!>!*/): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// Static members
public final var staticFun: J.Invoke!
}