952f67dafc
Previously, enum entries were treated by the data-flow subsystem similar to other class/singletons. As a consequence, calls like 'Enum.ENTRY.property' had IdentifierInfo of 'property'. However, specially for enum entries, descriptor of 'property' is one and the same for all entries. It means that from the data-flow point of view, 'Enum.ONE.property' and 'Enum.TWO.property' are *one and the same data-flow values*. It could obviously lead to some bogus smartcasts, so this commit introduces separate IdentifierInfo.EnumEntry and uses it to build proper qualified values. ^KT-20772 Fixed
20 lines
482 B
Kotlin
Vendored
20 lines
482 B
Kotlin
Vendored
// !LANGUAGE: -SoundSmartcastForEnumEntries
|
|
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
|
// SKIP_TXT
|
|
|
|
enum class Message(val text: String?) {
|
|
HELLO("hello"),
|
|
WORLD("world"),
|
|
NOTHING(null)
|
|
}
|
|
|
|
fun printMessages() {
|
|
Message.HELLO.text!!
|
|
<!DEBUG_INFO_SMARTCAST!>Message.HELLO.text<!>.length
|
|
|
|
<!DEBUG_INFO_SMARTCAST!>Message.NOTHING.text<!>.length
|
|
|
|
Message.NOTHING.text<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
|
<!DEBUG_INFO_SMARTCAST!>Message.NOTHING.text<!>.length
|
|
}
|