Files
kotlin-fork/translator/testFiles/expression/misc/cases/safecallComputesExpressionOnlyOnce.kt
T
Pavel Talanov 0d89e5d01f KT-962: Function is called two times
safecall expression now compute receiver only once.
2012-01-17 17:37:40 +04:00

14 lines
216 B
Kotlin

package foo
var i = 0
fun test() : Int? = i++
fun box() : Boolean {
if (i != 0) return false
test()?.plus(1)
if (i != 1) return false
test()?.minus(2)
if (i != 2) return false
return true
}