scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.72k stars 1.04k forks source link

JavaParsers doesn't support `JEP 445: Unnamed Classes and Instance Main Methods` #18584

Open xuwei-k opened 9 months ago

xuwei-k commented 9 months ago

Compiler version

Minimized code

Install JDK 21

A.java

void main() {
  System.out.println("hello");
}

B.scala

class B

build.sbt

javacOptions ++= Seq(
  "-Xlint:preview",
  "--enable-preview",
  "--release",
  scala.util.Properties.javaSpecVersion
)

scalaVersion := "3.3.1"

project/build.properties

sbt.version=1.9.6

sbt -J--enable-preview compile

Output

[error] 1 |void main() {
[error]   |     ^^^^
[error]   |     illegal start of type declaration
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

Expectation

success compile

Note

Kordyjan commented 9 months ago

3.3.2 will add support to JDK 21. We will probably need to take care of handling the new main methods.