Files
kotlin-fork/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.fir.kt
T
Denis.Zharkov da3233c47d FIR: Update test data (NEW_INFERENCE_ERROR)
Though these diagnostics look correct (the calls or constraint
systems indeed contain errors), more precise diagnostic kinds should be
chosen later.
2021-05-20 17:24:36 +03:00

30 lines
759 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
package a
interface A
fun <T>id(t: T): T = t
fun doList(l: List<Int>) = l
fun doInt(i: Int) = i
fun <T> strangeNullableList(f: (T) -> Unit): List<T>? = throw Exception()
fun <T: A> emptyNullableListOfA(): List<T>? = null
//-------------------------------
fun testExclExcl() {
doList(emptyNullableListOfA()!!) //should be an error here
val l: List<Int> = <!INITIALIZER_TYPE_MISMATCH, NEW_INFERENCE_ERROR!>id(emptyNullableListOfA()!!)<!>
doList(strangeNullableList { doInt(it) }!!) //lambda should be analyzed (at completion phase)
}
fun testDataFlowInfoAfterExclExcl(a: Int?) {
doInt(a!!)
a + 1
}
fun testUnnecessaryExclExcl(a: Int) {
doInt(a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>) //should be warning
}