Issue
I have a function with the following Swift code:
if value > bounds.lowerBound {
self.value -= 1
}
if value < bounds.upperBound {
self.value += 1
}
This gets transpiled to the following Kotlin code:
if (value > bounds.lowerBound) {
this.value -= 1
}
if (value < bounds.upperBound) {
this.value += 1
}
I'm getting an error from the compiler that refers to the following line:
if (value > bounds.lowerBound) {
and
if (value < bounds.upperBound) {
Unresolved reference. None of the following candidates is applicable because of a receiver type mismatch:
Proposed solution:
I think this:
if (value > bounds.lowerBound) {
}
needs to change to this:
if (value > bounds.start) {
}
and this:
if (value < bounds.upperBound) {
}
needs to change to this:
if (value < bounds.endInclusive) {
}
Workaround:
if isHigher(value: value, than: bounds) {
self.value -= 1
}
if isLower(value: value, than: bounds) {
self.value += 1
}
// SKIP REPLACE:
// private fun isHigher(value: Int, than: ClosedRange<Int>): Boolean {
// val bounds = than
// return value > bounds.start
// }
fileprivate func isHigher(value: Int, than bounds: ClosedRange<Int>) -> Bool {
return value > bounds.lowerBound
}
// SKIP REPLACE:
// private fun isLower(value: Int, than: ClosedRange<Int>): Boolean {
// val bounds = than
// return value < bounds.endInclusive
// }
fileprivate func isLower(value: Int, than bounds: ClosedRange<Int>) -> Bool {
return value < bounds.upperBound
}
Issue
I have a function with the following Swift code:
This gets transpiled to the following Kotlin code:
I'm getting an error from the compiler that refers to the following line:
if (value > bounds.lowerBound) {and
if (value < bounds.upperBound) {Unresolved reference. None of the following candidates is applicable because of a receiver type mismatch:
Proposed solution:
I think this:
needs to change to this:
and this:
needs to change to this:
Workaround: