-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add support for JEP-409 (sealed classes) + Add javacOpt directive #19080
Conversation
The scala 2 ticket links to the two PRs which may be helpful. The tricky part was that if permitted subclasses is not specified, you have to discover them in the source, but without requiring too much typechecking. |
Is this fix blocked by anything? |
No |
5e5021b
to
de004ca
Compare
CI needs (at least) Java 21 to pass. Waiting for #18873. |
private val directiveOptionsArg = raw"//> using options (.*)".r.unanchored | ||
private val directiveJavacOptions = raw"//> using javacOpt (.*)".r.unanchored |
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.
Inspired from scala-cli
directives :https://scala-cli.virtuslab.org/docs/reference/directives#javac-options
@@ -0,0 +1,7 @@ | |||
//> using javacOpt --enable-preview --source 17 |
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.
These options should be removed when CI is bumped to Java 21 (See #19701)
There is a current syntax that is not yet migrated to cli-style just for avoiding old jvm.
|
I'm familiar with this directive. I want to run the test at least once in the CI with the correct JVM before adding this directive. |
f94d219
to
11d0290
Compare
@@ -1569,7 +1570,7 @@ class Namer { typer: Typer => | |||
if pclazz.is(Final) then | |||
report.error(ExtendFinalClass(cls, pclazz), cls.srcPos) | |||
else if pclazz.isEffectivelySealed && pclazz.associatedFile != cls.associatedFile then | |||
if pclazz.is(Sealed) then | |||
if pclazz.is(Sealed) && !pclazz.is(JavaDefined) then |
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.
this would seem to allow extending a sealed Java class in a Scala file, perhaps use . Or could it be legitimate to define a permitted sub class in Scala?!isJava
instead which tests the compilation unit
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.
Actually it is allowed, If I compile with scalac Cat.scala
and Pet.java
in run 1, then javac on Pet.java
in run 2 with classpath of run 1 outputs, then it works
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.
maybe it could be interesting to add this as a test case in a follow up
Closes #18533
This PR also adds the following directive to the vulpix infrastructure:
//> using javacOpt *
inspired by : https://scala-cli.virtuslab.org/docs/reference/directives#javac-options