OpenJDK / amber / amber
changeset 57035:893b9bb5dd1f amber-demo-II
Automatic merge with records-and-sealed
author | mcimadamore |
---|---|
date | Thu, 22 Aug 2019 21:25:40 +0000 |
parents | f1f5f4dec514 7f79a7ab6de8 |
children | 75af95811f87 |
files | |
diffstat | 2 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Thu Aug 22 19:10:41 2019 +0000 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Thu Aug 22 21:25:40 2019 +0000 @@ -1156,7 +1156,7 @@ if (!types.isSameType(implSym.type.getReturnType(), tree.sym.type)) { log.error(TreeInfo.declarationFor(implSym, env.enclClass), Errors.AccessorReturnTypeDoesntMatch(tree.sym.type, implSym.type.getReturnType())); } - if (implSym.type.asMethodType().thrown.stream().filter(exc -> !isUnchecked(exc)).findAny().isPresent()) { + if (implSym.type.asMethodType().thrown.stream().anyMatch(exc -> !isUnchecked(exc))) { log.error(TreeInfo.declarationFor(implSym, env.enclClass), Errors.MethodCantThrowCheckedException); } } @@ -1303,7 +1303,7 @@ if (!canonicalInit.isPublic()) { log.error(canonicalDecl, Errors.CanonicalConstructorMustBePublic); } - if (canonicalInit.type.asMethodType().thrown.stream().filter(exc -> !isUnchecked(exc)).findAny().isPresent()) { + if (canonicalInit.type.asMethodType().thrown.stream().anyMatch(exc -> !isUnchecked(exc))) { log.error(TreeInfo.declarationFor(canonicalInit, env.enclClass), Errors.MethodCantThrowCheckedException); } // let's use the RECORD flag to mark it as the canonical constructor @@ -1432,6 +1432,9 @@ (types.supertype(owner().type).tsym == syms.enumSym)) { // constructors of true enums are private flags = PRIVATE | GENERATEDCONSTR; + } else if (owner().isRecord()) { + // record constructors are public + flags = PUBLIC | GENERATEDCONSTR; } else { flags = (owner().flags() & AccessFlags) | GENERATEDCONSTR; }
--- a/test/langtools/tools/javac/records/RecordCompilationTests.java Thu Aug 22 19:10:41 2019 +0000 +++ b/test/langtools/tools/javac/records/RecordCompilationTests.java Thu Aug 22 21:25:40 2019 +0000 @@ -359,4 +359,13 @@ " }\n" + "}"); } + + public void testNestedRecords() { + String template = + "class R { \n" + + " # record RR(int a) { }\n" + + "}"; + for (String s : List.of("", "static", "private", "private static")) + assertOK(template, s); + } }