Skip to content
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

Mixed compileOrder error with scala 3.0.0-M3 but success with 2.13.4 #10868

Closed
giabao opened this issue Dec 20, 2020 · 1 comment · Fixed by #11472
Closed

Mixed compileOrder error with scala 3.0.0-M3 but success with 2.13.4 #10868

giabao opened this issue Dec 20, 2020 · 1 comment · Fixed by #11472
Assignees
Milestone

Comments

@giabao
Copy link

giabao commented Dec 20, 2020

Minimized code

% mkdir -p project src/main/{scala,java}
% echo 'addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.1")' > project/plugins.sbt
% echo 'crossScalaVersions := Seq("2.13.4", "3.0.0-M3")' > build.sbt
% echo 'trait T { object O }' > src/main/scala/T.scala
% echo 'class J { T.O$ o; }' > src/main/java/J.java
% sbt ";clean ;++2.13.4 compile"
// success
% sbt ";clean ;++3.0.0-M3 compile"
[error] -- [E006] Not Found Error: /tmp/src/main/java/J.java:1:10 ------------
[error] 1 |class J { T.O$ o; }
[error]   |          ^
[error]   |          Not found: T

% echo 'compileOrder := CompileOrder.ScalaThenJava' >> build.sbt
% sbt ";clean ;++3.0.0-M3 compile"
// success

Output

Compile error (see above) in Mixed compileOrder with scala 3.0.0-M3 but success with 2.13.4

Expectation

Compile successfully as in scala 2.

Notes

% java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)
% eval "$(cs java --env --jvm 11)"
% java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)
@liufengyun
Copy link
Contributor

liufengyun commented Feb 19, 2021

The cause of the problem is that semanticDB generates a META-INF folder, and javac gets confused somehow.

Updated: incorrect, I get confused with the info.

The reason is that the JavaParser parses T.O$ to a select node, and the typer thinks that T is a term.

The Java parser has to way to determine in a selection A.B whether A is a type or a package. The typer has to try both. For simplicity, we can think A is a type name if it's captalized.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Feb 19, 2021
@liufengyun liufengyun self-assigned this Feb 19, 2021
liufengyun added a commit to dotty-staging/dotty that referenced this issue Feb 19, 2021
liufengyun added a commit to dotty-staging/dotty that referenced this issue Feb 19, 2021
This is the cheapest way to do it. There is no worry about
correctness, as the code will be compiled by javac again.
liufengyun added a commit to dotty-staging/dotty that referenced this issue Feb 19, 2021
smarter added a commit that referenced this issue Feb 24, 2021
Fix #10868: Handle semantic name in Java source code
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants