Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/externalArguments.fir.kt
T
Denis.Zharkov 2ecba6ac39 Remove WITH_NEW_INFERENCE directive from all tests
This directive anyway does not make test run twice with OI, and with NI
It only once run the test with specific settings (// LANGUAGE)
and ignores irrelevant (OI or NI tags)
2021-05-25 13:28:26 +03:00

37 lines
645 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.reflect.KProperty
fun testLambdaArgumentSmartCast(foo: Int?) {
val v = run {
if (foo != null)
return@run foo
15
}
}
class D {
operator fun getValue(ref: Any?, property: KProperty<*>): Int = 42
}
fun testSmartCastInDelegate(d: D?) {
if (d == null) return
val v: Int by d
}
fun testFunctionCallSmartcast(fn: (() -> Unit)?) {
if (fn == null) return
fn()
}
fun testCallableRefernceSmartCast() {
fun forReference() {}
val refernece = if (true) ::forReference else null
if (refernece == null)
return
refernece()
}