提交 1f729782 编写于 作者: M mcimadamore

7005671: Regression: compiler accepts invalid cast from X[] to primitive array

Summary: regression in type conversion after 292 changes
Reviewed-by: jjg
上级 3d39cfdf
......@@ -1080,7 +1080,8 @@ public class Types {
case CLASS:
return isSubtype(t, s);
case ARRAY:
if (elemtype(t).tag <= lastBaseTag) {
if (elemtype(t).tag <= lastBaseTag ||
elemtype(s).tag <= lastBaseTag) {
return elemtype(t).tag == elemtype(s).tag;
} else {
return visit(elemtype(t), elemtype(s));
......
/*
* @test /nodynamiccopyright/
* @author mcimadamore
* @bug 7005671
* @summary Regression: compiler accepts invalid cast from X[] to primitive array
* @compile/fail/ref=T7005671.out -XDrawDiagnostics T7005671.java
*/
class T7005671<X> {
void test1() {
Object o1 = (X[])(byte[])null;
Object o2 = (X[])(short[])null;
Object o3 = (X[])(int[])null;
Object o4 = (X[])(long[])null;
Object o5 = (X[])(float[])null;
Object o6 = (X[])(double[])null;
Object o7 = (X[])(char[])null;
Object o8 = (X[])(boolean[])null;
}
void test2() {
Object o1 = (byte[])(X[])null;
Object o2 = (short[])(X[])null;
Object o3 = (int[])(X[])null;
Object o4 = (long[])(X[])null;
Object o5 = (float[])(X[])null;
Object o6 = (double[])(X[])null;
Object o7 = (char[])(X[])null;
Object o8 = (boolean[])(X[])null;
}
}
T7005671.java:12:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), byte[], X[]
T7005671.java:13:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), short[], X[]
T7005671.java:14:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), int[], X[]
T7005671.java:15:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), long[], X[]
T7005671.java:16:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), float[], X[]
T7005671.java:17:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), double[], X[]
T7005671.java:18:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), char[], X[]
T7005671.java:19:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), boolean[], X[]
T7005671.java:23:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], byte[]
T7005671.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], short[]
T7005671.java:25:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], int[]
T7005671.java:26:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], long[]
T7005671.java:27:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], float[]
T7005671.java:28:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], double[]
T7005671.java:29:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], char[]
T7005671.java:30:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], boolean[]
16 errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册