Closed QasimCyrus closed 1 year ago
感谢指出问题,修复方案如下:
Test case:
+interface TestInterface1
interface TestInterface2
abstract class AbstactGenericAcitivty1<T : TestInterface1> : AppCompatActivity() {
@Autowired
var list = mutableListOf<String>()
}
abstract class AbstactGenericAcitivty2<T : TestInterface1, G:TestInterface2> : AppCompatActivity() {
@Autowired
var list = mutableListOf<String>()
}
@Route(path = "/app/TestAbstactGenericAcitivty1")
class TestAbstactGenericAcitivty1 : AbstactGenericAcitivty1<TestInterface1>(){
@Autowired
var t = mutableListOf<String>()
}
@Route(path = "/app/TestAbstactGenericAcitivty2")
class TestAbstactGenericAcitivty2 : AbstactGenericAcitivty2<TestInterface1, TestInterface2>(){
@Autowired
var t = mutableListOf<String>()
}
结果:
val substitute = (target as? AbstactGenericAcitivty1<*>)?: throw IllegalStateException(
"The target that needs to be injected must be AbstactGenericAcitivty1, please check your code!"
)
val substitute = (target as? AbstactGenericAcitivty2<*, *>)?: throw IllegalStateException(
"The target that needs to be injected must be AbstactGenericAcitivty2, please check your code!"
)
见README最新版本,请更新到xxx-1.0.4
如图,编写一个带有类型参数的泛型类,里面使用了 @Autowired 注解:
编译过程中报错,提示缺少泛型参数:
问题定位: