I have a Kotlin interface with a default implementation, for instance:
interface Foo {
fun bar(): String {
return "baz"
}
}
在我try 从Java实现这个接口之前,这是可以的.当我这样做的时候,它说这个类需要被标记为抽象的,或者实现方法bar()
.此外,当我try 实现该方法时,我无法调用super.bar()
.
I have a Kotlin interface with a default implementation, for instance:
interface Foo {
fun bar(): String {
return "baz"
}
}
在我try 从Java实现这个接口之前,这是可以的.当我这样做的时候,它说这个类需要被标记为抽象的,或者实现方法bar()
.此外,当我try 实现该方法时,我无法调用super.bar()
.
Please see the related issue.
comments 中有一条建议:
Write your interface in Java (with default methods) and both the Java and Kotlin classes correctly use those defaults