Files
kotlin-fork/compiler/testData/codegen/box/safeCall/kt247.kt
T
Alexander Udalov 41a416da60 Move blackBoxFile() testData to box/ directory
Delete all test methods (and empty test classes), since they'll be
auto-generated
2013-01-28 18:20:17 +04:00

39 lines
653 B
Kotlin

fun t1() : Boolean {
val s1 : String? = "sff"
val s2 : String? = null
return s1?.length == 3 && s2?.length == null
}
fun t2() : Boolean {
val c1: C? = C(1)
val c2: C? = null
return c1?.x == 1 && c2?.x == null
}
fun t3() {
val d: D = D("s")
val x = d?.s
if (!(d?.s == "s")) throw AssertionError()
}
fun t4() {
val e: E? = E()
if (!(e?.bar() == e)) throw AssertionError()
val x = e?.foo()
}
fun box() : String {
if(!t1 ()) return "fail"
if(!t2 ()) return "fail"
t3()
t4()
return "OK"
}
class C(val x: Int)
class D(val s: String)
class E() {
fun foo() = 1
fun bar() = this
}