n3o59hf
02/09/2016, 1:36 PMtailrec fun numbersum(i: Int, acc: Int=0) = if (i == 0) acc else numbersum(i - 1, acc + i)
Currently Kotlin compiler throws out exception:
ERROR: Rewrite at slice COMPILE_TIME_VALUE key: INTEGER_CONSTANT old value: IntegerValueType(1)@57604788 new value: IntegerValueType(1)@527224921
...
ERROR: Exception while analyzing expression at (17,41) in /home/elviss/tmp/inlinetest/src/main/kotlin/com/mycompany/myapp/Problem.kt:
if (i == 0) acc else numbersum(i - 1, acc + i)
...
and Idea suggests that easiest way to fix expression is to explicitly set return type of function.