dimanche 31 août 2014

How to fix this bug in the Kotlin Web Demo?


Vote count:

0




I'm a real n00b in Kotlin and have just started with its demo. There' no direct link, please click on Problems and then on Runs on the left.


The problem solution is trivial, but there's a bug in



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")
}


which I don't understand. It says



Type mismatch: inferred type is kotlin.Array<java.lang.StackTraceElement> but
kotlin.Array<java.lang.StackTraceElement?> was expected


and I can neither how the former was inferred nor why the latter is expected. Especially I don't understand where can two such assumption come from a single method call.


I "fixed" it by removing the offending lines, but I'm sure someone can enlighten me.



asked 43 secs ago







How to fix this bug in the Kotlin Web Demo?

Aucun commentaire:

Enregistrer un commentaire