For anyone seeing this compiler warning, it may be as simple as nesting your code inside a Unit aka { ... }
Kotlin allows us to assign functions:
fun doSomethingElse() = doSomething()
fun doSomething() { }
However, this doesn’t work if we’re calling the function recursively:
fun recursiveFunction(int: Int) =
when (int) {
1 -> { }
else -> recursiveFunction()
}
The fix is simple:
fun recursiveFunction(int: Int) {
when (int) {
1 -> { }
else -> recursiveFunction()
}
}