Closed
Description
Compiler version
Using Scala 3.0.0, I am unable to compile Java code that is generated by protoc (protobuf compiler). The following is a minimized version of the generated code to demonstrate the issue.
Minimized code
// src/main/java/mytest/Ex.java
package mytest;
public final class Ex {
private Ex() {}
public static final class Foo extends MyInterface {
private Foo() {
}
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new Foo();
}
}
}
// src/main/java/mytest/MyInterface.java
package mytest;
public class MyInterface {
public static final class UnusedPrivateParameter {};
}
The Scala code doesn't matter, but it needs to exist:
// src/main/scala/Main.scala
package foo
object Main {}
Output
sbt:ppp> compile
[info] compiling 1 Scala source and 2 Java sources to /tmp/ppp/target/scala-3.0.0/classes ...
[error] -- [E006] Not Found Error: /tmp/ppp/src/main/java/mytest/Ex.java:12:8 ----------
[error] 12 | UnusedPrivateParameter unused) {
[error] | ^^^^^^^^^^^^^^^^^^^^^^
[error] | Not found: type UnusedPrivateParameter
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed May 22, 2021, 10:36:18 AM
Expectation
Should compile with no errors.
Workaround
Adding compileOrder := CompileOrder.JavaThenScala
results in successful compilation.