x should be smart-cast to Int
# language-proposals
l
x should be smart-cast to Int
l
x
should be
Int
, not
Int?
since it's a
val
.
r
what if it was null?
I find this a valid case for all Comparable<A> and ClosedRange<A>
null is not in range and x being in range proofs is an Int. The contract system is not smart enough yet. @dmitriy.novozhilov Do you think ClosedRanges could constrain Comprable types to ensure smarcasting is applied in cases like this?
i
There's an issue about adding such a contract, but currently it's blocked by contracts not being supported for operator functions: https://youtrack.jetbrains.com/issue/KT-34132
👍 1
1