Files
kotlin-fork/idea/testData/checker/infos/SmartCastsWithSafeAccess.kt
T
Tianyu Geng f38c0cf348 FIR IDE: run FIR highlighting test on all test data
Similarly to FIR diagnostic tests. This commit enable all available test
data and check the reported error messages by FIR. This helps identify
some issues in formatting of FIR diagnostics.

The changes on the test file are mechanically generated. Failed tests
are disabled with `// IGNORE_FIR` and are re-enabled in the second
commit.
2021-03-29 12:45:27 +03:00

38 lines
658 B
Kotlin
Vendored

// FIR_IDENTICAL
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>
}
}