Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/smartcastOnSameFieldOfDifferentInstances.kt
T
Dmitry Savvinov 62edf29cbf Use DataFlowValue instead of Descriptor for equality of ESDataFlowValue
Equality of those values is crucial for intersecting data-flow info
coming from expressions like: 'this.x != null || other.x != null'.

Using 'ValueDescriptor' for equality is obviously wrong, because then 'this.x'
and 'other.x' will be treated as equal, leading to unsound smartcasts.

This commit adds proper overload of 'equals' to 'ESDataFlowValue' that
will compare them based on underlying 'DataFlowValue' (which already
distinguish those values)

^KT-27260 Fixed
2018-10-02 11:05:06 +03:00

11 lines
233 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"
x<!UNSAFE_CALL!>.<!>length > 0 -> "2"
}
}
}