6886247: regression: javac crashes with an assertion error in Attr.java

Capture conversion does not work on nested types

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2010-08-19 11:50:50 +01:00
parent d7787c25cf
commit 71962ebfb0
4 changed files with 90 additions and 0 deletions

View File

@ -2945,6 +2945,13 @@ public class Types {
public Type capture(Type t) {
if (t.tag != CLASS)
return t;
if (t.getEnclosingType() != Type.noType) {
Type capturedEncl = capture(t.getEnclosingType());
if (capturedEncl != t.getEnclosingType()) {
Type type1 = memberType(capturedEncl, t.tsym);
t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments());
}
}
ClassType cls = (ClassType)t;
if (cls.isRaw() || !cls.isParameterized())
return cls;

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6886247
* @author Maurizio Cimadamore
* @summary regression: javac crashes with an assertion error in Attr.java
* @compile T6886247_1.java
*/
class Outer<E> {
public void method(Outer<? extends E>.Inner inner) {
E entry = inner.getE();
}
class Inner {
E getE() {return null;}
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6886247
* @author Maurizio Cimadamore
* @summary regression: javac crashes with an assertion error in Attr.java
* @compile/fail/ref=T6886247_2.out -XDrawDiagnostics T6886247_2.java
*/
class Outer<E> {
public void method(Outer<?>.Inner inner) {
E entry = inner.getE();
}
class Inner {
E getE() {return null;}
}
}

View File

@ -0,0 +1,2 @@
T6886247_2.java:35:28: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.type.captureof: 1, ?, E
1 error