Recursive type parameter and the class of 'this'

Viewed 97

Can we ensure that A<T> is always an instance of T?

open class A<T : A<T>> {
  fun self(): T = this as T // is this safe?
}

or are there any cases where it's not true?

0 Answers
Related