mcpiroman
12/31/2021, 3:18 PMabstract class Base<T : Any>(val clazz: KClass<T>)
class Foo; class Bar;
object A : Base<Foo>(Foo::class) { ... }
object B : Base<Bar>(Bar::class) { ... }
Can I somehow 'reifine' the `T`paramater so I only have to write the parameter class once, e.g. `Base<Foo>()`or Base(Foo::class)
?
Edit: OK, it's fine that it's possible but I actually meant to ask 'how' to do that. The 2 ways I suggested above do not compile, nor can I use `reified`modifier.kqr
01/02/2022, 7:43 PMturansky
01/03/2022, 12:03 AMinline <reified T> fun Base(): Base<T> =
Base(T::class)
mcpiroman
01/07/2022, 1:33 PMabstract class Base<T : Any>(val clazz: KClass<T>)
inline fun<reified T : Any> Base2(): Base<T> = Base(T::class) // Cannot create an instance of an abstract class
class Foo;
object A : Base2<Foo>() // You can't extend from an invocation of function