Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/varnotnull/plusplusMinusminus.fir.kt
T
Jinseong Jeon e72ddbcbfe FIR checker: differentiate UNSAFE_CALL from INAPPLICABLE_CANDIDATE
To do so, inside the root cause of inapplicable candidate errors,
we will record expected/actual type of receiver, if any.
That will help identifying inapplicable calls on nullable receiver.
2021-01-29 16:54:23 +03:00

22 lines
392 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
fun foo(arg: Int?): Int {
var i = arg
if (i != null && i++ == 5) {
return i-- + i
}
return 0
}
operator fun Long?.inc() = this?.let { it + 1 }
fun bar(arg: Long?): Long {
var i = arg
if (i++ == 5L) {
return i<!UNSAFE_CALL!>--<!> + i
}
if (i++ == 7L) {
return i++ <!NONE_APPLICABLE!>+<!> i
}
return 0L
}