Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 为什么可以';注释类不能推断类型参数吗? 让我们考虑这个代码: @Target(AnnotationTarget.FIELD) annotation class DeserializeInterface<T: Any>(val targetClass: KClass<T>) interface A class B : A class Test { @DeserializeInterface<B>(B::class) val a: A = B() }_Kotlin_Type Inference - Fatal编程技术网

Kotlin 为什么可以';注释类不能推断类型参数吗? 让我们考虑这个代码: @Target(AnnotationTarget.FIELD) annotation class DeserializeInterface<T: Any>(val targetClass: KClass<T>) interface A class B : A class Test { @DeserializeInterface<B>(B::class) val a: A = B() }

Kotlin 为什么可以';注释类不能推断类型参数吗? 让我们考虑这个代码: @Target(AnnotationTarget.FIELD) annotation class DeserializeInterface<T: Any>(val targetClass: KClass<T>) interface A class B : A class Test { @DeserializeInterface<B>(B::class) val a: A = B() },kotlin,type-inference,Kotlin,Type Inference,但是为什么呢?这是当前类型推断算法的一个限制。我已经提交了一份你可以跟踪的文件 class AClass<T: Any>(val a: List<T>) fun main(args: Array<String>) { val a = AClass(listOf(1,2,3)) }

但是为什么呢?

这是当前类型推断算法的一个限制。我已经提交了一份你可以跟踪的文件

class AClass<T: Any>(val a: List<T>)

fun main(args: Array<String>) {
    val a = AClass(listOf(1,2,3))
}