changeset 56898:d4e8276ce5b3 records-and-sealed

sealed classes subtypes can be implicit if in same compilation unit
author vromero
date Mon, 24 Jun 2019 18:38:44 -0400
parents 4b162290687a
children 93144cfc2d71 f44032b6dbad
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jun 24 18:07:26 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jun 24 18:38:44 2019 -0400
@@ -4804,9 +4804,10 @@
 
         for (Pair<ClassType, JCExpression> sealedParentPair: potentiallySealedParents) {
             if (!sealedParentPair.fst.permitted.map(t -> t.tsym).contains(c.type.tsym)) {
-                boolean areNestmates = sealedParentPair.fst.tsym.outermostClass() == tree.sym.outermostClass();
+                boolean areInSameCompilationUnit = TreeInfo.declarationFor(sealedParentPair.fst.tsym, env.toplevel) != null &&
+                        TreeInfo.declarationFor(tree.sym.outermostClass(), env.toplevel) != null;
                 boolean isSealed = sealedParentPair.fst.tsym.isSealed();
-                if (areNestmates) {
+                if (areInSameCompilationUnit) {
                     if (sealedParentPair.fst.tsym.isSealed() && !((ClassType)sealedParentPair.fst.tsym.type).isPermittedExplicit) {
                         sealedParentPair.fst.permitted = sealedParentPair.fst.permitted.prepend(tree.sym.type);
                     } else if (!dontErrorIfSealedExtended) {