Need help with Kotlin-Java interop! ``` //Tasks.k...
# announcements
a
Need help with Kotlin-Java interop!
Copy code
//Tasks.kt
abstract class Foo : Callable<Unit> {   
    override fun call() { bar() }
    abstract fun bar()
}

//Manager.java
public class FooChild extends Tasks.Foo {
    @Override public void bar() { //haha }
}
Class FooChild is highlighed as Error with message: 'call()' in 'Tasks.Foo' clashes with 'call()' in 'java.util.concurrent.Callable'; attempting to use incompatible return type
Somewhy it creates another call() method marked as
public synthetic bridge
. Here's bytecode:
Copy code
// access flags 0x1
public call()V
 L0
  LINENUMBER 93 L0
  ALOAD 0
  INVOKEVIRTUAL Tasks$Foo.bar ()V
  RETURN
 L1
  LOCALVARIABLE this LTasks$Foo; L0 L1 0
  MAXSTACK = 1
  MAXLOCALS = 1
// access flags 0x1041
public synthetic bridge call()Ljava/lang/Object;
 L0
  LINENUMBER 91 L0
  ALOAD 0
  INVOKEVIRTUAL Tasks$Foo.call ()V
  GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit;
  ARETURN
  MAXSTACK = 1
  MAXLOCALS = 1
d
In java:
public kotlin.Unit call()
a
Are you suggesting to override the method
Call
?
d
What I'm suggesting is that you dont use void but the actual return type of the function. I misread the function name though.