提交 6c826307 编写于 作者: M mcimadamore

6680106: StackOverFlowError for Cyclic inheritance in TypeParameters with ArrayType Bounds

Summary: Javac ends up in an infinite loop while attributing mutually referring array type-parameter bounds
Reviewed-by: jjg
上级 feb70bd2
......@@ -2520,7 +2520,10 @@ public class Attr extends JCTree.Visitor {
// accept class or interface or typevar as first bound.
Type b = checkBase(bs.head, tree.bounds.head, env, false, false, false);
boundSet.add(types.erasure(b));
if (b.tag == TYPEVAR) {
if (b.isErroneous()) {
a.bound = b;
}
else if (b.tag == TYPEVAR) {
// if first bound was a typevar, do not accept further bounds.
if (tree.bounds.tail.nonEmpty()) {
log.error(tree.bounds.tail.head.pos(),
......@@ -2534,7 +2537,9 @@ public class Attr extends JCTree.Visitor {
for (JCExpression bound : tree.bounds.tail) {
bs = bs.tail;
Type i = checkBase(bs.head, bound, env, false, true, false);
if (i.tag == CLASS)
if (i.isErroneous())
a.bound = i;
else if (i.tag == CLASS)
chk.checkNotRepeated(bound.pos(), types.erasure(i), boundSet);
}
}
......
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6680106
* @summary StackOverFlowError for Cyclic inheritance in TypeParameters with ArrayType Bounds
* @author Maurizio Cimadamore
* @compile/fail/ref=T6680106.out -XDrawDiagnostics T6680106.java
*/
class T6680106 {
class A0 {}
class A1<T extends T[]> {}
class A2<T extends S[], S extends T[]> {}
class A3<T extends S[], S extends U[], U extends T[]> {}
class A5<T extends A0 & T[]> {}
class A6<T extends A0 & S[], S extends A0 & T[]> {}
class A7<T extends A0 & S[], S extends A0 & U[], U extends A0 & T[]> {}
}
T6680106.java:34:25: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:35:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:35:40: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:36:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:36:40: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class)
T6680106.java:36:55: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:37:30: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:38:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:38:50: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
T6680106.java:39:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
T6680106.java:39:50: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class)
T6680106.java:39:70: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
12 errors
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册