Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8259905: Compiler treats 'sealed' keyword as 'var' keyword #2298

Conversation

vicente-romero-oracle
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle commented Jan 28, 2021

Hi,

Please review this fix which is basically fixing an oversaw issue affecting new restricted keywords: sealed and permits. The fix per se is in lines: 3341-3343, but then I made some additional changes to the position where previous errors were reported at method JavacParser::variableDeclaratorRest. That was done for consistency with the new code. I could have done the other way but then users would have two error notifications for some code, one for the use of the restricted type per se and another one for the use of the variable or field so like:

void m() {
    sealed s1;
    ^
    compiler error here
           ^
                and before you go, compiler error here too
}

I guess it make sense for the already existing code to be positioned on the use of the restricted type and not on the variable declared afterwards. Doing that adjustment has implied some changes to the golden file associated to test ParserTest. Also I added another case and did some additional editing to test SealedCompilationTests.

TIA


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8259905: Compiler treats 'sealed' keyword as 'var' keyword

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2298/head:pull/2298
$ git checkout pull/2298

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 28, 2021

👋 Welcome back vromero! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 28, 2021
@openjdk
Copy link

openjdk bot commented Jan 28, 2021

@vicente-romero-oracle The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jan 28, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 28, 2021

Webrevs

@lahodaj
Copy link
Contributor

lahodaj commented Jan 28, 2021

Looking at the spec here:
http://cr.openjdk.java.net/~gbierman/jep397/jep397-20201204/specs/sealed-classes-jls.html

It does not seem to exclude sealed from TypeIdentifier (as the specs exclude var, yield and record). So it should be possible to have a class named "sealed"? Seems sealed is a keyword only on particular places, like e.g. open? But possibly I am not reading the spec properly?

@mlbridge
Copy link

mlbridge bot commented Jan 28, 2021

Mailing list message from Gavin Bierman on compiler-dev:

No that is an omission. `sealed` and `permits` should be classified as restricted identifiers (new concept to JLS 16) and thus not valid type identifiers. I?ll fix this in the next version of the spec.

Gavin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210128/3054b83b/attachment-0001.htm>

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openjdk
Copy link

openjdk bot commented Jan 29, 2021

@vicente-romero-oracle This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8259905: Compiler treats 'sealed' keyword as 'var' keyword

Reviewed-by: jlahoda

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 77 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 29, 2021
@vicente-romero-oracle
Copy link
Contributor Author

/integrate

@openjdk openjdk bot closed this Jan 29, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 29, 2021
@openjdk
Copy link

openjdk bot commented Jan 29, 2021

@vicente-romero-oracle Since your change was applied there have been 83 commits pushed to the master branch:

  • 6415d3b: 8259584: SuperWord::fix_commutative_inputs checks in_bb(fin1) instead of in_bb(fin2)
  • b7b391b: 8260625: Rename MetaspaceExpand_lock
  • 22bfa5b: 8255837: Shenandoah: Remove ShenandoahConcurrentRoots class
  • 53f1b93: 8260518: Change default -mmacosx-version-min to 10.12
  • 24a2621: 8260592: jpackage tests fail when Desktop is not supported
  • d2b0ea1: 8260282: Add option to compress heap dumps created by -XX:+HeapDumpOnOutOfMemoryError
  • a5fb517: 8259404: Shenandoah: Fix time tracking in parallel_cleaning
  • 0675473: 8252409: JShell: Intersection types cause NoSuchFieldError
  • 64a150c: 6986863: ProfileDeferralMgr throwing ConcurrentModificationException
  • ea2c447: 8259778: Merge MutableSpace and ImmutableSpace
  • ... and 73 more: https://git.openjdk.java.net/jdk/compare/d076977d036f141f2a3d57a373ecdb6ecdc4a7a9...master

Your commit was automatically rebased without conflicts.

Pushed as commit b2e582a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
2 participants