Files
kotlin-fork/compiler/testData/diagnostics/tests/when/withSubjectVariable/smartCastsOnSubjectVariable.fir.kt
T

9 lines
243 B
Kotlin
Vendored

// !LANGUAGE: +VariableDeclarationInWhenSubject
fun test(x: Any?) =
when (val y = x) {
is String -> "String, length = ${y.length}"
null -> "Null"
else -> "Any, hashCode = ${y.hashCode()}"
}