bug icon indicating copy to clipboard operation
bug copied to clipboard

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

Open xuwei-k opened this issue 1 year ago • 0 comments

Reproduction steps

  • Scala 2.13.12
  • JDK 21
  • https://openjdk.org/jeps/445
  • https://github.com/xuwei-k/Scala-JEP-445/commit/c96fe40572021d937935d448026e7b2cdff0dca1
  • https://github.com/xuwei-k/Scala-JEP-445/actions/runs/6268842307/job/17024415920

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 := "2.13.12"

project/build.properties

sbt.version=1.9.6

Problem

sbt -J--enable-preview compile

https://github.com/scala/scala/blob/e67d287447c09720468f8bebcb0302bd92d75f43/src/compiler/scala/tools/nsc/javac/JavaParsers.scala#L1074

[error] /home/runner/work/Scala-JEP-445/Scala-JEP-445/A.java:1:6: illegal start of type declaration
[error] void main() {
[error]      ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

xuwei-k avatar Sep 22 '23 01:09 xuwei-k