https://kotlinlang.org logo
i

Ian

03/18/2017, 3:36 AM
Am I doing this right? My Store needs a KClass<T> internally for Gson serialization. Since constructors can’t be reified, I’m using an inline function as follows:
Copy code
inline fun <reified T : Any> Store(directory : Path) = Store(directory, T::class)
class Store<T : Any>(val directory: Path, private val kc: KClass<T>) { … }
I think this works, but I’d really like to hide the Store constructor that takes the KClass from the public API, but inline functions can’t call a constructor with lower visibility. I feel like I must be missing something…?