Proposal: Provide a keyword or magic type `This` t...
# language-proposals
b
Proposal: Provide a keyword or magic type
This
that can be used to say "The parameter's type is the sub- or implementing-class' type" So:
Copy code
interface Foo<T> {
    fun example(other: This): T
}

class Bar: Foo<Int> {
    fun example(other: Bar): Int {
        TODO()
    }
}

class Baz<T>: Foo<T> {
    fun example(other: Foo<T>): T { // Old style gets a compile error: must be Baz or a subclass of Baz
        TODO()
    }
}