I have an interface `Gateway` and a class paramete...
# getting-started
f
I have an interface
Gateway
and a class parameter
KClass<Gateway>
. But when I pass an instance of
KClass<GatewayImpl>
, the compiler complains. Is there a way around this? Casting works, so something is correct.
y
Use
KClass<out Gateway>
r
This article explains this in a clear way: https://typealias.com/guides/ins-and-outs-of-generic-variance/
f
Thanks! I thought I tried that, but turns out I forgot to remove the casting 😬