Prohibit Array<Nothing>

This commit is contained in:
Alexey Tsvetkov
2015-11-27 12:57:34 +03:00
parent 35f788a89c
commit 7384d25cb3
8 changed files with 154 additions and 5 deletions
@@ -0,0 +1,54 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNCHECKED_CAST -USELESS_CAST
class A<T>
fun test1(
a: <!UNSUPPORTED!>Array<Nothing><!>,
b: <!UNSUPPORTED!>Array<Nothing?><!>,
c: <!UNSUPPORTED!>Array<in Nothing><!>,
d: <!UNSUPPORTED!>Array<in Nothing?><!>,
e: <!UNSUPPORTED!>Array<out Nothing><!>,
f: <!UNSUPPORTED!>Array<out Nothing?><!>
) {}
fun test2(
a: <!UNSUPPORTED!>Array<Nothing><!>?,
b: <!UNSUPPORTED!>Array<Nothing?><!>?,
c: <!UNSUPPORTED!>Array<in Nothing><!>?,
d: <!UNSUPPORTED!>Array<in Nothing?><!>?,
e: <!UNSUPPORTED!>Array<out Nothing><!>?,
f: <!UNSUPPORTED!>Array<out Nothing?><!>?
) {}
fun test3(
a: A<<!UNSUPPORTED!>Array<Nothing><!>>,
b: A<<!UNSUPPORTED!>Array<Nothing?><!>>,
c: A<<!UNSUPPORTED!>Array<in Nothing><!>>,
d: A<<!UNSUPPORTED!>Array<in Nothing?><!>>,
e: A<<!UNSUPPORTED!>Array<out Nothing><!>>,
f: A<<!UNSUPPORTED!>Array<out Nothing?><!>>
) {}
fun test4(
a: Array<A<Nothing>>,
b: Array<A<Nothing?>>,
c: Array<A<in Nothing>>,
d: Array<A<in Nothing?>>,
e: Array<A<out Nothing>>,
f: Array<A<out Nothing?>>
) {}
fun test5() {
<!UNSUPPORTED!><!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>arrayOf<!><Nothing>()<!>
<!UNSUPPORTED!><!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Array<!><Nothing>(10) { throw Exception() }<!>
}
fun <T> foo(): Array<T> = (object {} as Any) as Array<T>
fun test6() = <!UNSUPPORTED!>foo<Nothing>()<!>
class B<T>(val array: Array<T>)
fun <T> bar() = B<Array<T>>(arrayOf())
fun test7() = <!UNSUPPORTED!>bar<Nothing>()<!>
@@ -0,0 +1,26 @@
package
public fun </*0*/ T> bar(): B<kotlin.Array<T>>
public fun </*0*/ T> foo(): kotlin.Array<T>
public fun test1(/*0*/ a: kotlin.Array<kotlin.Nothing>, /*1*/ b: kotlin.Array<kotlin.Nothing?>, /*2*/ c: kotlin.Array<in kotlin.Nothing>, /*3*/ d: kotlin.Array<in kotlin.Nothing?>, /*4*/ e: kotlin.Array<out kotlin.Nothing>, /*5*/ f: kotlin.Array<out kotlin.Nothing?>): kotlin.Unit
public fun test2(/*0*/ a: kotlin.Array<kotlin.Nothing>?, /*1*/ b: kotlin.Array<kotlin.Nothing?>?, /*2*/ c: kotlin.Array<in kotlin.Nothing>?, /*3*/ d: kotlin.Array<in kotlin.Nothing?>?, /*4*/ e: kotlin.Array<out kotlin.Nothing>?, /*5*/ f: kotlin.Array<out kotlin.Nothing?>?): kotlin.Unit
public fun test3(/*0*/ a: A<kotlin.Array<kotlin.Nothing>>, /*1*/ b: A<kotlin.Array<kotlin.Nothing?>>, /*2*/ c: A<kotlin.Array<in kotlin.Nothing>>, /*3*/ d: A<kotlin.Array<in kotlin.Nothing?>>, /*4*/ e: A<kotlin.Array<out kotlin.Nothing>>, /*5*/ f: A<kotlin.Array<out kotlin.Nothing?>>): kotlin.Unit
public fun test4(/*0*/ a: kotlin.Array<A<kotlin.Nothing>>, /*1*/ b: kotlin.Array<A<kotlin.Nothing?>>, /*2*/ c: kotlin.Array<A<in kotlin.Nothing>>, /*3*/ d: kotlin.Array<A<in kotlin.Nothing?>>, /*4*/ e: kotlin.Array<A<out kotlin.Nothing>>, /*5*/ f: kotlin.Array<A<out kotlin.Nothing?>>): kotlin.Unit
public fun test5(): kotlin.Unit
public fun test6(): kotlin.Array<kotlin.Nothing>
public fun test7(): B<kotlin.Array<kotlin.Nothing>>
public final class A</*0*/ T> {
public constructor A</*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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B</*0*/ T> {
public constructor B</*0*/ T>(/*0*/ array: kotlin.Array<T>)
public final val array: kotlin.Array<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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -3,8 +3,8 @@
inline fun<reified T> foo(block: () -> T): String = block().toString()
fun box() {
val a = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>arrayOf<!>(null!!)
val b = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Array<!><Nothing?>(5) { null!! }
val a = <!UNSUPPORTED!><!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>arrayOf<!>(null!!)<!>
val b = <!UNSUPPORTED!><!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Array<!><Nothing?>(5) { null!! }<!>
val c = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!>() { null!! }
val d = foo<Any> { null!! }
val e = <!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>foo<!> { "1" as Nothing }