This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified K : Any> summon(): K { | |
val tpe = typeOf<K>() | |
return summon(tpe) as? K | |
?: error("Trait instance must be of type $tpe") | |
} | |
// FIXME: Come up with a way to make it sufficiently weak to prevent | |
// memory leaks due to accumulation of the underlying classes | |
// if class loaders are being closed. | |
private val instances = ConcurrentHashMap<KType, Any>() |