nadi
02/17/2024, 10:09 PMJoffrey
02/17/2024, 11:30 PMClass<T> is invariant in its type parameter, so by default Class<MyIntImp> is not a subtype of Class<MyInt> even if MyIntImp is a subtype of MyInt.
You probably want Class<out MyInt> (with the out modifier) in your annotation declaration, not just Class<MyInt>. You can learn more about generics and variance here:
https://kotlinlang.org/docs/generics.htmlnadi
02/18/2024, 8:30 AMnadi
02/18/2024, 8:30 AMnadi
02/19/2024, 2:59 PMJoffrey
02/19/2024, 4:16 PMMyInt have an in or out modifier on its own type parameter? Because that is what decides whether the subtyping relationship between MyInt<T> and MyInt<U> depends on the subtyping relationship between T and U.Joffrey
02/19/2024, 4:18 PMClass<T> example, you might have an issue. Class<MyInt<A>> doesn't really carry any meaning in itself, because the Class instance of a generic class/interface doesn't care about the type parameter.