https://kotlinlang.org logo
#announcements
Title
# announcements
k

karelpeeters

11/09/2017, 6:46 AM
You can do it using a self type, eg:
Copy code
abstract class Foo<S: Foo<S>>{
  fun common(): S = copy()
  abstract fun copy(): S
}

class Bar: Foo<Bar> {
  override fun copy() = Bar()
}

Bar().common() //returns a Bar instance