I have applied the latest update to Idea 12 (129.671) and it asked me to update the Kotlin runtime, so I did.
Now I am having compile errors that I don’t know how to fix (everything is green in idea, but it doesn’t compile).
public trait TaskObject {
public fun run(): String?
public fun pre()
public fun post(abort: Runnable?)
public fun success(s: String)
public fun failure(canceled: Boolean)
public fun abort()
}
internal abstract class AbstractTaskObject(val link: String?): TaskObject {
public override fun success(s: String) {}
public override fun post(abort: Runnable?) {}
public override fun pre() {}
public override fun failure(canceled: Boolean) {}
public override fun abort() = if (link != null) updateLink(link)
}
…
return object:AbstractTaskObject(link) {
public override fun pre() { … }
public override fun run() { … }
}
And I am gettting this error for the anonymous impl:
Kotlin: Object must be declared abstract or implement abstract member public abstract fun post(abort: (() -> jet.Unit)?): jet.Unit defined in com.uncopt.android.task.TaskObject
Any suggestion on how to fix the compile error?
It looks like there’s some kind of auto-conversion going on between Runnable and ()->Unit and the compiler gets confused.
public override fun listFiles(uri: String, sort: Comparator<String>?) = null
… must be declared abstract or implement abstract member public abstract fun listFiles(uri: jet.String, sort: ((jet.String, jet.String) -> jet.Int)?): jet.List<jet.String>? defined in …
Can you provide more information? Like Kotlin plugin version, full sources.
The following code works for me, and for You?
public trait TaskObject {
public fun run(): String?
public fun pre()
public fun post(abort: Runnable?)
public fun success(s: String)
public fun failure(canceled: Boolean)
public fun abort()
}
internal abstract class AbstractTaskObject(val link: String?): TaskObject {
public override fun success(s: String) {}
public override fun post(abort: Runnable?) {}
public override fun pre() {}
public override fun failure(canceled: Boolean) {}
public override fun abort() = Unit.VALUE //if (link != null) updateLink(link)
}
fun foo(): AbstractTaskObject {
return object:AbstractTaskObject(“”) {
public override fun pre() { }
public override fun run() = “”
}
}