Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/variables/ifNullAssignment.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

74 lines
1.3 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// See KT-13468, KT-13765
fun basic(): String {
var current: String? = null
current = if (current == null) "bar" else current
return <!DEBUG_INFO_SMARTCAST!>current<!>
}
fun foo(flag: Boolean) {
var x: String? = null
if (x == null) {
x = if (flag) "34" else "12"
}
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
}
fun bar(flag: Boolean) {
var x: String? = null
if (x == null) {
x = when {
flag -> "34"
else -> "12"
}
}
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
}
fun baz(flag: Boolean) {
var x: String? = null
if (x == null) {
x = if (flag) {
"34"
} else {
"12"
}
}
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
}
fun gav(flag: Boolean, arg: String?) {
var x: String? = null
if (x == null) {
x = arg ?: if (flag) {
"34"
} else {
"12"
}
}
<!DEBUG_INFO_SMARTCAST!>x<!>.hashCode()
}
fun gau(flag: Boolean, arg: String?) {
var x: String? = null
if (x == null) {
x = if (flag) {
arg ?: "34"
} else {
arg ?: "12"
}
}
<!DEBUG_INFO_SMARTCAST{NI}!>x<!><!UNSAFE_CALL{OI}!>.<!>hashCode()
}