我试图写这样的东西:
var classList = ArrayList<Class<Any>>()
init {
classList.add(ClassA::class.java)
classList.add(ClassB::class.java)
}
这给我带来了错误:
Type inference failed. Expected type mismatch: inferred type is Class<ClassA> but Class<Any> was expected
我可以通过做一个明确的演员来摆脱错误:
domainClasses.add(NameIdMapping::class.java as Class<Any>)
这让我成为一名未经检查的演员&#34;警告。这是我能做的最好的吗?如何干净利落地做到这一点?