Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/externalArguments.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

38 lines
780 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_VARIABLE
// !WITH_NEW_INFERENCE
import kotlin.reflect.KProperty
fun testLambdaArgumentSmartCast(foo: Int?) {
val v = run {
if (foo != null)
return@run <!DEBUG_INFO_SMARTCAST{NI}!>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 <!DEBUG_INFO_SMARTCAST!>d<!>
}
fun testFunctionCallSmartcast(fn: (() -> Unit)?) {
if (fn == null) return
<!DEBUG_INFO_SMARTCAST!>fn<!>()
}
fun testCallableRefernceSmartCast() {
fun forReference() {}
val refernece = if (true) ::forReference else null
if (refernece == null)
return
<!DEBUG_INFO_SMARTCAST!>refernece<!>()
}