Hi,
Unfortunately I feel that something’s still wrong here. Because this causes an error in 1.0.5
source.readByte() == 1
Operator ‘==’ cannot be applied to ‘Byte’ and ‘Int’
Doesn’t anyone working on Kotlin feel that something is missing? At the very least for literal values here that are obviously convertible? You want, we all want this code to be easier to write and read than Java. Doesn’t this fail?
Doesn’t anyone working on Kotlin feel that something is missing?
Yes, that feels not good, as to me, that’s why we have an issue regarding literal conversions https://youtrack.jetbrains.com/issue/KT-3936 open. We have discussed it recently and we plan to fix it in some of the next versions of Kotlin.
The proper solution in a generic way would be to introduce the concept of compile time constant as a type property for values (with the value). This would mean making the type system more complex with the benefit of both treating numeric constants (and literals) nicer as well as introducing further opportunities for optimisation. I’m not sure that the generic approach is worth it though, but at least it is mainly a compiler only feature (no language syntax changes involved).