Files
kotlin-fork/idea/testData/checker/infos/SmartCastsWithSafeAccess.kt
T
Mikhail Glukhikh 1780f7c9a2 Put not-null original type as last possible smart cast target
This fixes muted tests testSmartCast (IDE highlighting) and
testNestedSealed (Diagnostics).
Together with commit 555b3f12 this makes #KT-15901 Fixed
2017-03-23 17:17:37 +03:00

36 lines
640 B
Kotlin
Vendored

interface A {
fun foo()
}
interface B : A {
fun bar()
}
interface C
interface D : A
fun test(a: A?) {
if (a != null && a is B?) {
<info descr="Smart cast to B">a</info>.bar()
}
if (a is B && a is C) {
<info descr="Smart cast to B">a</info>.foo()
}
if (a is B? && a is C?) {
<info descr="Smart cast to B?">a</info><info>?.</info>bar()
}
a<info>?.</info>foo()
if (a is B? && a is C?) {
a<info>?.</info>foo()
}
if (a is B && a is D) {
//when it's resolved, the message should be 'Smart cast to A'
<info>a</info>.<error>foo</error>
}
}