Files
kotlin-fork/compiler/testData/ir/irText/expressions/elvis.kt.txt
T
Dmitriy Novozhilov b454fcc1e0 [FIR] Save IR dumps to .ir.txt files instead of .txt in tests
This is needed to avoid clashes between different dumps from different
  handlers
2021-10-12 17:26:36 +03:00

64 lines
1.1 KiB
Plaintext
Vendored

val p: Any?
field = null
get
fun foo(): Any? {
return null
}
fun test1(a: Any?, b: Any): Any {
return { // BLOCK
val tmp0_elvis_lhs: Any? = a
when {
EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> b
else -> tmp0_elvis_lhs
}
}
}
fun test2(a: String?, b: Any): Any {
return { // BLOCK
val tmp0_elvis_lhs: String? = a
when {
EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> b
else -> tmp0_elvis_lhs
}
}
}
fun test3(a: Any?, b: Any?): String {
when {
b !is String -> return ""
}
when {
a !is String? -> return ""
}
return { // BLOCK
val tmp0_elvis_lhs: String? = a /*as String? */
when {
EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> b /*as String */
else -> tmp0_elvis_lhs
}
}
}
fun test4(x: Any): Any {
return { // BLOCK
val tmp0_elvis_lhs: Any? = <get-p>()
when {
EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> x
else -> tmp0_elvis_lhs
}
}
}
fun test5(x: Any): Any {
return { // BLOCK
val tmp0_elvis_lhs: Any? = foo()
when {
EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> x
else -> tmp0_elvis_lhs
}
}
}