abstract class Base interface Stackable class SubA : Base(), Stackable class SubB: Base() val things: List = listOf(SubA(), SubB()) fun get(type: KClass): T { return things.first { it::class == type } as T } fun get(type: KClass): List { return things.first { it::class == type } as List }