Kotlin koans不工作? 我疯了吗?

Kotlin koan 3,“Default Arguments”,似乎很简单,但我解决不了:

fun foo(name: String = "", number: Int = 42, toUpperCase: Boolean = false): String { if(!toUpperCase) return name+number else return name.toUpperCase()+number } fun task3(): String { // todoTask3() return ( foo("a") + foo("b", number = 1) + foo("c", toUpperCase = true) + foo(name = "d", number = 2, toUpperCase = true)) } 

在Intellij中,第一个“+”符号被标记为错误,带有一个恶意的长堆栈跟踪:

 Error:(27, 22) Kotlin: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: @InlineOnly public operator inline fun BigDecimal.plus(other: BigDecimal): BigDecimal defined in kotlin @InlineOnly public operator inline fun BigInteger.plus(other: BigInteger): BigInteger defined in kotlin public operator fun <T> Array<???>.plus(elements: Array<out ???>): Array<???> defined in kotlin.collections public operator fun <T> Array<???>.plus(elements: Collection<???>): Array<???> defined in kotlin.collections public operator fun <T> Array<String>.plus(element: String): Array<String> defined in kotlin.collections public operator fun BooleanArray.plus(element: Boolean): BooleanArray defined in kotlin.collections public operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray defined in kotlin.collections public operator fun BooleanArray.plus(elements: Collection<Boolean>): BooleanArray defined in kotlin.collections public operator fun ByteArray.plus(element: Byte): ByteArray defined in kotlin.collections public operator fun ByteArray.plus(elements: ByteArray): ByteArray defined in kotlin.collections public operator fun ByteArray.plus(elements: Collection<Byte>): ByteArray defined in kotlin.collections @InlineOnly public operator inline fun Char.plus(other: String): String defined in kotlin.text public operator fun CharArray.plus(element: Char): CharArray defined in kotlin.collections public operator fun CharArray.plus(elements: CharArray): CharArray defined in kotlin.collections public operator fun CharArray.plus(elements: Collection<Char>): CharArray defined in kotlin.collections public operator fun DoubleArray.plus(element: Double): DoubleArray defined in kotlin.collections public operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray defined in kotlin.collections public operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray defined in kotlin.collections public operator fun FloatArray.plus(element: Float): FloatArray defined in kotlin.collections public operator fun FloatArray.plus(elements: FloatArray): FloatArray defined in kotlin.collections public operator fun FloatArray.plus(elements: Collection<Float>): FloatArray defined in kotlin.collections public operator fun IntArray.plus(element: Int): IntArray defined in kotlin.collections public operator fun IntArray.plus(elements: IntArray): IntArray defined in kotlin.collections public operator fun IntArray.plus(elements: Collection<Int>): IntArray defined in kotlin.collections public operator fun LongArray.plus(element: Long): LongArray defined in kotlin.collections public operator fun LongArray.plus(elements: LongArray): LongArray defined in kotlin.collections public operator fun LongArray.plus(elements: Collection<Long>): LongArray defined in kotlin.collections public operator fun ShortArray.plus(element: Short): ShortArray defined in kotlin.collections public operator fun ShortArray.plus(elements: ShortArray): ShortArray defined in kotlin.collections public operator fun ShortArray.plus(elements: Collection<Short>): ShortArray defined in kotlin.collections public operator fun String?.plus(other: Any?): String defined in kotlin public operator fun String?.plus(other: Any?): String defined in kotlin public operator fun <T> Collection<???>.plus(elements: Array<out ???>): List<???> defined in kotlin.collections public operator fun <T> Collection<???>.plus(elements: Iterable<???>): List<???> defined in kotlin.collections public operator fun <T> Collection<???>.plus(elements: Sequence<???>): List<???> defined in kotlin.collections public operator fun <T> Collection<String>.plus(element: String): List<String> defined in kotlin.collections public operator fun <T> Iterable<???>.plus(elements: Array<out ???>): List<???> defined in kotlin.collections public operator fun <T> Iterable<???>.plus(elements: Iterable<???>): List<???> defined in kotlin.collections public operator fun <T> Iterable<???>.plus(elements: Sequence<???>): List<???> defined in kotlin.collections public operator fun <T> Iterable<String>.plus(element: String): List<String> defined in kotlin.collections public operator fun <K, V> Map<out ???, ???>.plus(pairs: Array<out Pair<???, ???>>): Map<???, ???> defined in kotlin.collections public operator fun <K, V> Map<out ???, ???>.plus(pair: Pair<???, ???>): Map<???, ???> defined in kotlin.collections public operator fun <K, V> Map<out ???, ???>.plus(pairs: Iterable<Pair<???, ???>>): Map<???, ???> defined in kotlin.collections public operator fun <K, V> Map<out ???, ???>.plus(map: Map<out ???, ???>): Map<???, ???> defined in kotlin.collections public operator fun <K, V> Map<out ???, ???>.plus(pairs: Sequence<Pair<???, ???>>): Map<???, ???> defined in kotlin.collections public operator fun <T> Set<???>.plus(elements: Array<out ???>): Set<???> defined in kotlin.collections public operator fun <T> Set<???>.plus(elements: Iterable<???>): Set<???> defined in kotlin.collections public operator fun <T> Set<???>.plus(elements: Sequence<???>): Set<???> defined in kotlin.collections public operator fun <T> Set<String>.plus(element: String): Set<String> defined in kotlin.collections public operator fun <T> Sequence<???>.plus(elements: Array<out ???>): Sequence<???> defined in kotlin.sequences public operator fun <T> Sequence<???>.plus(elements: Iterable<???>): Sequence<???> defined in kotlin.sequences public operator fun <T> Sequence<???>.plus(elements: Sequence<???>): Sequence<???> defined in kotlin.sequences public operator fun <T> Sequence<String>.plus(element: String): Sequence<String> defined in kotlin.sequences 

如果我将第一个调用从foo(“a”)更改为foo(“a”)。toString(),

我得到以下内容:

org.junit.Comparison

 Failure: Expected :a42b1C42D2 Actual :kotlin.Unitb1C42D2 

所以它实际上是返回“kotlin.Unit”?

我在做什么愚蠢的事情?

Kotlin language will be the best programming language for Android.