-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Java parser: add support for JEP-445 #18790
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
Conversation
4053e13
to
a55e5bc
Compare
a55e5bc
to
01540b0
Compare
This is now ready for review. To run newly introduced compilation tests in CI, lampepfl/dotty-ci#24 needs to be released.
Thanks for working on this! Here are my thoughts after a first look at it, let me know if you'd like more guidance.
-
For reference, while the JEP itself lacks some details, spec changes are available:
-
Because all this stuff is still experimental, we need some mechanism to not enable it by default, normally we'd use
@experimental
but that only works for Scala code, so it's not clear to me what we should do here, adding a temporary -Y flag might be our best bet /cc @sjrd -
If I understand the spec correctly, user code should not be able to refer to an unnamed class by its compiler-synthesized name. Luckily we do have a flag to express this already:
Invisible
, so the JavaParser should set this flag, and we need tests to ensure it works properly here. -
The changes to the main method resolution in the JVMS will need to be reflected in a few places (I guess this could be handled in a separate PR since just being able to compile code would already be useful):
- https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/config/Platform.scala#L45-L49
- https://github.com/lampepfl/dotty/blob/052bce44c6eccc7b6a0bf6cba3141e79a205e68a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala#L23-L28
- https://github.com/lampepfl/dotty/blob/052bce44c6eccc7b6a0bf6cba3141e79a205e68a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala#L256-L259
- It's possible sbt will need to be adjusted to correctly deal with the mainClass we feed it from ExtractAPI, but that's something we can worry about later as long as we keep this stuff experimental on our side.
A -Y
flag would be perfectly fine here. We don't have to deal with pollution of experimental products since the actual products are created by javac.
Starting a draft PR for #18584