Compile Error with Runnable arg after runtime update


#1

Hi,

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.


#2

Same thing with Comparator<String>?:

  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 …


#3

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() = “”
  }
}


#4

Plugin version is 0.5.742

I created a simple project to try to isolate the problem.

If the trait is in the same module it works.

But if it’s another module, then it doesn’t.

I have attached the project.



test02.zip (675 KB)

#5

Thank you! We'll investigate it.


#6

We have fixed this problem, please update Kotlin plugin from plugin repository.   


#7

Thank you. I updated as you suggested and it works now.