-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
feature: add support for java 14 switch/yield #3314
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MartinWitt
commented
Mar 25, 2020
That's a serious PR, thanks a lot! Will look at it in detail. |
monperrus
reviewed
Mar 27, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed it, it looks really good, congrats for understanding all the code generation infrastructure.
- in pom.xml could you remove the space changes?
- see also inline comments
Thanks!
remove wrong comment
Thanks. Could you add this explanation in the source code directly?
|
MartinWitt
changed the title
WIP: Feature: java 14 switch/yield
Feature: java 14 switch/yield
Mar 30, 2020
monperrus
changed the title
Feature: java 14 switch/yield
feature: add support for java 14 switch/yield
Apr 1, 2020
Thanks a lot @MartinWitt it's awesome that we now support Java 14! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Java 14 Switches
Jep361 defines a new switchExpression.
@Egor18 implemented them already without yield( awesome work btw).
This pr adds support for java14 switches with yield and with this change spoon supports all java14 features that are non preview(records and textblocks are only part of jdt beta branch and still preview)
Whats part of this PR
Consequences
There are 2 consequence expect more code.
spoon loses the ability to parse java 12 preview code with break [expression]
Currently spoon supports them, but i would instantly drop support for a feature that was never part java (only preview) and wont come back.
Yield
replaces this.Supported preview features should be seen as an experimental feature and i hope no one is relaying on them.
####junit5 in testclasses####
I cant guarantee that every testrunner in everyones IDE fully supports junit5.
I would be nice if you could test the refactored SwitchCaseTest.
Reward is a much clearer design for the testclasses.
upgrading jdt to 3.20 produced 2 problems
Luckily there were only 2 visible problems after upgrading it.
break.isImplicit
flag was removedwasn't a big problem, because there are no longer needed.
PackageBinding.java was changed to a abstract class
Is a bigger problem, but current there is a fix.
For (potential) fix see src/main/java/spoon/support/compiler/jdt/ReferenceBuilder.java#363
Maybe someone with more knowledge about this class could review it.
interesting more academic fact
Is allowed code
but the following is not allowed.
This behavior seems intended, because looking at java grammar we find:
SwitchRule:
SwitchLabel -> Expression ;
SwitchLabel -> Block
SwitchLabel -> ThrowStatement
and yield is not an expression but a StatementWithoutTrailingSubstatement from my understanding.
tl;dr;