mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
6675483: Javac rejects multiple type-variable bound declarations starting with an enum type
Intersection types bounded by an enum are erroeously considered harmful by javac Reviewed-by: jjg
This commit is contained in:
parent
5f46dc3001
commit
fbde930522
2 changed files with 41 additions and 1 deletions
|
@ -2664,7 +2664,7 @@ public class Attr extends JCTree.Visitor {
|
||||||
// Enums may not be extended by source-level classes
|
// Enums may not be extended by source-level classes
|
||||||
if (st.tsym != null &&
|
if (st.tsym != null &&
|
||||||
((st.tsym.flags_field & Flags.ENUM) != 0) &&
|
((st.tsym.flags_field & Flags.ENUM) != 0) &&
|
||||||
((c.flags_field & Flags.ENUM) == 0) &&
|
((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0) &&
|
||||||
!target.compilerBootstrap(c)) {
|
!target.compilerBootstrap(c)) {
|
||||||
log.error(env.tree.pos(), "enum.types.not.extensible");
|
log.error(env.tree.pos(), "enum.types.not.extensible");
|
||||||
}
|
}
|
||||||
|
|
40
langtools/test/tools/javac/enum/T6675483.java
Normal file
40
langtools/test/tools/javac/enum/T6675483.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue