Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/smartcastOnSameFieldOfDifferentInstances.kt
T
Dmitry Savvinov dd682bd37d Add test on data-flow
Idea is to intersect similar smartcasts on similar properties coming
from *different* instances (something like
'this.x == null && other.x == null' ).

It checks that we distinguish subjects of such smartcasts properly.

Currently behavior is undesired, see KT-27260
2018-10-02 11:05:06 +03:00

11 lines
242 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_EXPRESSION
// See KT-27260
class A(val x: String?) {
fun foo(other: A) {
when {
x == null && other.x == null -> "1"
<!DEBUG_INFO_SMARTCAST!>x<!>.length > 0 -> "2"
}
}
}