changeset 674:c655e0280bdc

6886247: regression: javac crashes with an assertion error in Attr.java Summary: capture conversion does not work on nested types Reviewed-by: jjg
author mcimadamore
date Thu, 19 Aug 2010 11:50:50 +0100
parents a31c511db424
children d6fe0ea070aa
files src/share/classes/com/sun/tools/javac/code/Types.java test/tools/javac/generics/wildcards/6886247/T6886247_1.java test/tools/javac/generics/wildcards/6886247/T6886247_2.java test/tools/javac/generics/wildcards/6886247/T6886247_2.out
diffstat 4 files changed, 90 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Aug 16 14:59:21 2010 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Aug 19 11:50:50 2010 +0100
@@ -2945,6 +2945,13 @@
     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;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/wildcards/6886247/T6886247_1.java	Thu Aug 19 11:50:50 2010 +0100
@@ -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;}
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/wildcards/6886247/T6886247_2.java	Thu Aug 19 11:50:50 2010 +0100
@@ -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;}
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/wildcards/6886247/T6886247_2.out	Thu Aug 19 11:50:50 2010 +0100
@@ -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