2
我是Kotlin的一個真正的n00b,剛剛開始使用demo。如何修復Kotlin Web Demo中的這個錯誤?
問題的解決方案是微不足道的,但有一個在
private fun assertEquals<T>(actual : T?, expected : T?, message : Any? = null) {
if (actual != expected) {
errors++
println("Test failed")
val trace = Thread.currentThread()?.getStackTrace()!!
if (trace.size > 6) {
// Finding relevant stack frames
val location = trace.getFrameAfter("runs.Tester", "expect") // ERROR HERE
val function = trace.getFrameAfter("runs.TesterRunner", "forFunction") // AND HERE
println("at ${function?.getClassName()}.${function?.getMethodName()}(line:${location?.getLineNumber()})")
}
if (message != null)
println(message)
}
else if (!skipSuccessful)
println("OK")
}
我不明白的錯誤。它說
Type mismatch: inferred type is kotlin.Array<java.lang.StackTraceElement> but
kotlin.Array<java.lang.StackTraceElement?> was expected
我既不能如何推斷前者,也不能推測後者爲什麼。特別是我不明白哪裏有兩個這樣的假設來自單個方法調用。
我通過刪除有問題的線條來「固定」它,但我確定有人可以啓發我。
爲了提高可讀性,我已將* italics *(*)更改爲'code quote'(')。 – JustinJDavies 2014-09-01 08:50:28
我完全錯過了「痕跡」的聲明,這很清楚。謝謝。 – maaartinus 2014-09-01 12:50:41