Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/ArrayOfNothing.kt
T
Alexander Udalov 6ba32ed624 Refactor CallChecker and subclasses
Encapsulate everything that is needed in checkers into CallCheckerContext. Pass
an instance of this context instead of BasicCallResolutionContext to checkers.

Also pass an instance of the element to report errors on: this is useful
because before this, every checker had its own way of determining where should
the error be reported on. Some of them, for example, were not doing anything if
Call#calleeExpression returned null, which is wrong, see operatorCall.kt

 #KT-12875 Open
2016-06-29 19:20:00 +03:00

55 lines
1.5 KiB
Kotlin
Vendored

// !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!>arrayOf<!><<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>Nothing<!>>()
<!UNSUPPORTED!>Array<!><<!REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>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>()