Restrict interface extensions to certain classes

Hi,

in Swift I’m using the where clause to restrict extensions of interfaces to certain classes. I’m using the extension to create default implementations which need access to parameters of certain classes. Is this also possible with Kotlin?

class A

interface B

extension interface B when A implements B.
or
extension class A when it implements interface B

Thanks in advance!

Seems like intersection type or multiple bounded generics to me. That should work:

open class OpenType

interface Marker

class MarkedType : OpenType(), Marker

class UnmarkedType : OpenType()

fun <T> T.extention() where T : OpenType, T : Marker = println("1234")

fun main(args: Array<String>) {
	MarkedType().extention()
	UnmarkedType().extention() // doesn't compile
}