import kotlin.reflect.KClass fun main(args: Array) { val x = Test() x.prop = "instance for string" println(Test().prop) } class Test private constructor() { lateinit var prop: F companion object { private val instances = hashMapOf, Test<*>>() inline operator fun invoke(): Test = getInstance(S::class) fun getInstance(type: KClass<*>): Test = instances[type] as? Test ?: run { val result = Test() instances.put(type, result) result } } }