6675483: Javac rejects multiple type-variable bound declarations starting with an enum type
authormcimadamore
Fri, 25 Jul 2008 12:22:09 +0100
changeset 941 2589047a9c5d
parent 940 0d5cabfaffde
child 942 98e1d4f8aacd
6675483: Javac rejects multiple type-variable bound declarations starting with an enum type Summary: Intersection types bounded by an enum are erroeously considered harmful by javac Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/test/tools/javac/enum/T6675483.java
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Jul 25 12:05:43 2008 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Jul 25 12:22:09 2008 +0100
@@ -2664,7 +2664,7 @@
                 // Enums may not be extended by source-level classes
                 if (st.tsym != null &&
                     ((st.tsym.flags_field & Flags.ENUM) != 0) &&
-                    ((c.flags_field & Flags.ENUM) == 0) &&
+                    ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0) &&
                     !target.compilerBootstrap(c)) {
                     log.error(env.tree.pos(), "enum.types.not.extensible");
                 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/enum/T6675483.java	Fri Jul 25 12:22:09 2008 +0100
@@ -0,0 +1,40 @@
+/*
+ * 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 6675483
+ *
+ * @summary Javac rejects multiple type-variable bound declarations starting with an enum type
+ * @author Maurizio Cimadamore
+ *
+ * @compile T6675483.java
+ */
+
+public class T6675483 {
+    enum E implements Comparable<E> {}
+
+    interface C<T extends E & Comparable<E>> {
+        <S extends E & Comparable<E>> void m();
+    }
+}