I have the following pattern: ```abstract class Ba...
# getting-started
m
I have the following pattern:
Copy code
abstract 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.
👌 2
k
@turansky @Guilherme D. Fernandes hm?
t
Copy code
inline <reified T> fun Base(): Base<T> =
    Base(T::class)
🙇‍♂️ 1
1
m
@turansky That does not work
Copy code
abstract 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