Smart cast to 'LinkOrigin.ActionButtonLink' is impossible, because 'event.origin' is a public API property declared in different module
LinkOrigin
is sealed class in the different module indeed. But why is it the problem?
k
Klitos Kyriacou
05/23/2023, 4:45 PM
It's because the
origin
property is defined in a different module, which is separately compiled, and therefore the compiler can't be sure that repeated accesses of this property will return the same value.
e
Eugen Martynov
05/23/2023, 8:57 PM
You mean that it doesn’t have kotlin meta data or this bytecode is java and could be changed?
k
Klitos Kyriacou
05/24/2023, 8:31 AM
A separately compiled module can be Kotlin or Java code, and in both cases smart casts are not applied on properties. I'm not sure if the Kotlin metadata on a property says whether or not it can return a different value between calls. But certainly a Java getXxxx() method can.
e
Eugen Martynov
05/24/2023, 8:36 AM
Thank you. I don’t remember it being the case before. Some inconvenience for sure.