Generic extending class AND implements interface in Kotlin

Only one upper bound can be specified inside the angle brackets.

Kotlin offers different syntax for generic constraints when there is more than one constraint:

class Foo<T>(val t: T) where T : Bar, T : Baz { ... }

and for functions:

fun <T> f(): Foo where T : Bar, T : Baz { ... }

It is documented here.

Leave a Comment