Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/smartcasts/unsoundSmartcast.fir.kt
T
Nikolay Lunyak a68a2409d3 [FIR] Remove the applicability filtering when reporting diagnostics
In case we don't want to introduce any new
abstractions like "user relevance for
applicability", we can just remove the
filtering.

^KT-62541 Fixed
2023-10-19 09:27:45 +00:00

42 lines
997 B
Kotlin
Vendored

// SKIP_TXT
// ISSUE: KT-30507
fun test1() {
var x: MutableList<Int>? = mutableListOf(1)
x!!
x[if (true) { x = null; 0 } else 0] += <!UNSAFE_CALL!>x[0]<!>
<!UNSAFE_CALL!>x[0]<!>.inv()
}
fun test2() {
var x: MutableList<Int>? = mutableListOf(1)
x!!
x[if (true) { x = null; 0 } else 0] = 11
<!UNSAFE_CALL!>x[0]<!>.inv()
}
fun test3() {
var x: MutableList<Int>? = mutableListOf(1)
x!!
x[0] = if (true) { x = null; 0 } else 0
<!UNSAFE_CALL!>x[0]<!>.inv()
}
operator fun MutableList<Int>.get(i1: Int, i2: Int) {}
operator fun MutableList<Int>.set(i1: Int, i2: Int, el: Int) = 10
fun test4() {
var x: MutableList<Int>? = mutableListOf(1)
x!!
val y = x[if (true) { x = null; 0 } else 0, <!UNSAFE_CALL!>x[0]<!>]
}
operator fun Int.invoke(y: Int, z: Int) {}
fun test5() {
var x: Int? = 10
x!!
<!UNSAFE_IMPLICIT_INVOKE_CALL!>x<!>(if (true) { x = null; 0 } else 0, <!ARGUMENT_TYPE_MISMATCH!>x<!>)
x<!UNSAFE_CALL!>.<!>inv()
}