Skip to content

scala.tools.nsc.javac.JavaParsers can't parse JDK14 records #11908

Closed
scala/scala
#9551
@xuwei-k

Description

@xuwei-k

reproduction steps

https://openjdk.java.net/jeps/359

https://github.com/scala/scala/blob/a20345d2380dfc63ff0aa41d4ab97b538a9f74a7/src/compiler/scala/tools/nsc/javac/JavaParsers.scala#L874

$ java --version
openjdk 14 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

build.sbt

javacOptions ++= Seq("--enable-preview", "--release", "14")
scalaVersion := "2.13.1"

A.java

package aaa;

public record A(int x, int y) { }

B.scala

package bbb

class B {
  def x = new aaa.A(3, 4)
}

sbt version 1.3.8

problem

A.java:3:15: illegal start of type declaration
[error] public record A(int x, int y) { }
[error]               ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

expectation

no error.

workaround

// build.sbt
compileOrder := CompileOrder.JavaThenScala

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions