Question: This is probably because I'm using an ol...
# getting-started
k
Question: This is probably because I'm using an older version of Kotlin, but with the version of Kotlin that I am using, it seems like I have to explicitly override whenever I have a situation like this:
Copy code
interface Base<T> {
  fun doSomething(): T
}
interface IntBase : Base<Int> {
  override fun doSomething() = 0
}

interface MyInterface : Base<Int>, IntBase {
  override fun doSomething() = super.doSomething()
}
It seems like I am required to have the line in
MyInterface
, despite only inheriting a default implementation from only one place. Is this normal, or is it because I'm using an older version of Kotlin?
j
Which version of Kotlin are you using? This compiles fine without the override even in Kotlin 1.2: https://pl.kotl.in/60k6K3tYk
Did you try this exact code? Maybe your simplification made the example too different from your real code
g
k
Try
Copy code
interface Base<T> {
  val value: T
}
interface IntBase : Base<Int> {
  override val value get() = 0
}

interface MyIntBase : Base<Int>, IntBase
The compiler is saying that I have to explicitly override
value
in
MyIntBase
, despite there being only one super-interface where a default implementation is provided.
j
That's exactly what I did in the playground link above and it works in Kotlin 1.2.71 and 2.2.20-Beta1
k
Odd. My project is configured to build with language version 1.9 against a 1.8 API. It is a KMP project, but the code is in
commonMain
, so it probably shouldn't matter since the only platform-specific code is JVM at the moment.