```abstract class Base {} class Sub : Base() {} a...
# getting-started
r
Copy code
abstract class Base {}
class Sub : Base() {}

abstract class Foo {
    abstract val x: KClass<Base>
}
class Bar: Foo {
    override val x: KClass<Base> = Sub::class
/*
    Type mismatch.
    Required: KClass<Base>
    Found: KClass<Sub>
 */
}
How to fix?
y
Change it to
KClass<out Base>
r
what does out mean?
also is there a way for me to create an alias to not have to type
KClass<out Base>
all the time
can I do like
Copy code
type Cls<T> = KClass<out T>
y
Yeah you can do that with
typealias
. The issue here btw is that KClass is invariant, but you want to use it similar to how a list is used, as in that it should "output" things of type
Base
, hence the
out
projected type