changeset 60085:01e18578f527 amber-demo-II

Automatic merge with sealed-types
author mcimadamore
date Wed, 26 Feb 2020 01:00:50 +0000
parents 965b8b804f43 335223833edc
children 749031d7910f
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java
diffstat 3 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Feb 24 22:21:18 2020 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Feb 26 01:00:50 2020 +0000
@@ -5019,6 +5019,7 @@
             Env<AttrContext> env = typeEnvs.get(c);
 
             if (c.isSealed() &&
+                    !c.isEnum() &&
                     !((ClassType)c.type).isPermittedExplicit &&
                     ((ClassType)c.type).permitted.isEmpty()) {
                 log.error(env.tree, Errors.SealedTypeMustHaveSubtypes);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Mon Feb 24 22:21:18 2020 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Feb 26 01:00:50 2020 +0000
@@ -1336,7 +1336,7 @@
         JCClassDecl cdef = (JCClassDecl) tree;
         for (JCTree defs: cdef.defs) {
             defs.accept(sts);
-            if (sts.specialized) return 0;
+            if (sts.specialized) return SEALED;
         }
         return FINAL;
     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Mon Feb 24 22:21:18 2020 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Wed Feb 26 01:00:50 2020 +0000
@@ -849,7 +849,7 @@
                         for (Type supertype : potentiallySealedSuperTypes) {
                             if (!((ClassType)supertype).permitted.map(t -> t.tsym).contains(tree.sym.type.tsym)) {
                                 if (!((ClassType)supertype.tsym.type).isPermittedExplicit) {
-                                    if (tree.sym.isAnonymous()) {
+                                    if (tree.sym.isAnonymous() && !tree.sym.isEnum()) {
                                         log.error(findTreeReferringSym(tree, supertype.tsym), Errors.CantInheritFromSealed(supertype.tsym));
                                     } else {
                                         ((ClassType)supertype).permitted = ((ClassType)supertype).permitted.append(tree.sym.type);
@@ -874,7 +874,7 @@
                     log.error(tree, Errors.NonSealedWithNoSealedSupertype);
                 }
 
-                if (hasSuperTypesInSealedHierarchy && tree.sym.isLocal()) {
+                if (hasSuperTypesInSealedHierarchy && tree.sym.isLocal() && !tree.sym.isEnum()) {
                     log.error(tree, Errors.LocalClassesCantExtendSealed);
                 }