Java 推断:类型变量的上限是数组类型
Java inference : type variable with an upper bound that is an array type
我对 JLS 第三版和推理机制有疑问。 15.12.2.7 部分指出:
If F = U[], where the type U involves Tj, then if A is an array type
V[], or a type variable with an upper bound that is an array type V[]
我试图创建一个具有数组类型上限的类型变量,但这似乎不被编译器接受。类似于:
public class MyClass<T extends String []> {
}
我的问题是:这个片段中的 JLS 是错误的,还是我遗漏了什么?句子的后半部分对我来说似乎无法满足。
谢谢
来自以下错误的详细信息:
https://bugs.openjdk.java.net/browse/JDK-6557960
JLS 有点不连贯,如第 4.4 节所述:
Type variables have an optional bound, T & I 1 ... I n . The bound
consists of either a type variable, or a class or interface type T
类型变量不能有数组类型的bound,这与我上面问题(来自15.12.2.7部分)中提到的部分矛盾:
or a type variable with an upper bound that is an array type V[]
这部分可以简单地忽略,因为它永远无法满足。
非常感谢 biziclop link
我对 JLS 第三版和推理机制有疑问。 15.12.2.7 部分指出:
If F = U[], where the type U involves Tj, then if A is an array type V[], or a type variable with an upper bound that is an array type V[]
我试图创建一个具有数组类型上限的类型变量,但这似乎不被编译器接受。类似于:
public class MyClass<T extends String []> {
}
我的问题是:这个片段中的 JLS 是错误的,还是我遗漏了什么?句子的后半部分对我来说似乎无法满足。
谢谢
来自以下错误的详细信息:
https://bugs.openjdk.java.net/browse/JDK-6557960
JLS 有点不连贯,如第 4.4 节所述:
Type variables have an optional bound, T & I 1 ... I n . The bound consists of either a type variable, or a class or interface type T
类型变量不能有数组类型的bound,这与我上面问题(来自15.12.2.7部分)中提到的部分矛盾:
or a type variable with an upper bound that is an array type V[]
这部分可以简单地忽略,因为它永远无法满足。
非常感谢 biziclop link