Bloop can't compile Dotty
Closed this issue · 4 comments
It's a known issue: using Bloop as the build server with Metals when working on the Dotty codebase does not work. For this reason, the official "Getting Started" instructions advise to use "SBT" as the build server instead: https://dotty.epfl.ch/docs/contributing/setting-up-your-ide.html#metals-1.
However, using SBT as the build server is suboptimal because 1. it's an additional step to explain to newcomers, and 2. commands issues by Metals are mixed and matched with user-issued commands, making it troublesome to work with.
Reproduce with:
$ git clone git@github.com:lampepfl/dotty.git dotty-fresh
$ cd dotty-fresh
$ code .
After bloopInstall
, Indexing…
and re-compilation terminate, Bloop reports a compilation error for scala3-compiler
and autocompletion doesn't work (try for example with compiler/src/dotty/tools/dotc/typer/Typer.scala
).
Note some other features such as "Go to definition" do work as expected.
Metals Doctor shows scala3-compiler
compilation failed:
The compilation error reported by Bloop is in QuotesImpl.scala
:
Same error from the CLI:
$ bloop compile scala3-compiler
Compiling scala3-compiler (567 Scala sources and 8 Java sources)
[E] [E1] compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala:285:31
[E] Not found: type ValOrDefDefMethods
[E] L285: given ValOrDefDefMethods: ValOrDefDefMethods with
[E] ^^^^^^^^^^^^^^^^^^
[E] compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala: L285 [E1]
Compiled scala3-compiler (26779ms)
[E] Failed to compile 'scala3-compiler'
ValOrDefDefMethods
was introduced in 3.4. It is probably getting confused because of the missing ValOrDefDefMethods
in Quotes
of 3.3.1.
We might need to wait until we get 3.4.0
. We could not update the reference compiler due to 3.4.0-RC1
due to conflicting TASTy minor versions on experimental versions of the compiler. This will happen each time we update to a new minor release.
In the Bloop configuration of scala3-compiler
we have:
"dependencies": [
"scala3-interfaces",
"scala3-library",
"tasty-core"
],
"classpath": [
"/home/piquerez/github/lampepfl/dotty-fresh/.bloop/scala3-interfaces/classes",
"/home/piquerez/github/lampepfl/dotty-fresh/.bloop/scala3-library/scala-3/classes",
"/home/piquerez/github/lampepfl/dotty-fresh/.bloop/tasty-core/scala-3/classes",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-asm/9.6.0-scala-1/scala-asm-9.6.0-scala-1.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/compiler-interface/1.9.6/compiler-interface-1.9.6.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-reader/3.19.0/jline-reader-3.19.0.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal/3.19.0/jline-terminal-3.19.0.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal-jna/3.19.0/jline-terminal-jna-3.19.0.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/util-interface/1.9.8/util-interface-1.9.8.jar",
"/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/net/java/dev/jna/jna/5.3.1/jna-5.3.1.jar"
],
So scala3-compiler
should have all the new scala3-library
classes in its classpath, including ValOrDefDefMethods
. But I suspect Bloop to automatically add scala3-library_3_3.3.1.jar
in the classpath, which shadows ValOrDefDefMethods
.
A fix for this issue would be to export the autoScalaLibrary := false
from sbt configuration to Bloop configuration.
Some more info:
If I run bloop compile scala3-compiler --verbose
I got:
[D][zinc] The Scala compiler is invoked with:
-feature
-deprecation
-unchecked
-encoding
UTF8
-language:implicitConversions
-source
3.3
-Yexplicit-nulls
-Ysafe-init
-Xsemanticdb
-sourceroot
/home/piquerez/github/lampepfl/dotty-fresh
-bootclasspath
/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.1/scala3-library_3-3.3.1.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar
-classpath
/home/piquerez/github/lampepfl/dotty-fresh/compiler/resources:/home/piquerez/github/lampepfl/dotty-fresh/compiler/target/scala-3.3.1/resource_managed/main:/home/piquerez/github/lampepfl/dotty-fresh/.bloop/scala3-compiler/bloop-internal-classes/classes-bloop-cli-xg3iHKTwQIWW9vIulmpDeQ==-B7Qn2fdlQquxMpXpNk26pw==:/home/piquerez/github/lampepfl/dotty-fresh/.bloop/scala3-compiler/scala-3/classes-empty-scala3-compiler:/home/piquerez/.cache/bloop/semanticdb/com.sourcegraph.semanticdb-javac.0.9.9/semanticdb-javac-0.9.9.jar:/home/piquerez/github/lampepfl/dotty-fresh/.bloop/scala3-interfaces/bloop-internal-classes/classes-bloop-cli-9EhtLXZmQjOcZD6HxhPGeQ==-98YFALWFSuiu-bQbGpsbig==:/home/piquerez/github/lampepfl/dotty-fresh/.bloop/scala3-library/bloop-internal-classes/classes-bloop-cli-9EhtLXZmQjOcZD6HxhPGeQ==-cQ40KjbrRhik8m_NnNJatA==:/home/piquerez/github/lampepfl/dotty-fresh/.bloop/tasty-core/bloop-internal-classes/classes-bloop-cli-9EhtLXZmQjOcZD6HxhPGeQ==-JgASU2SjSq6fT9q_-ssNCw==:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-asm/9.6.0-scala-1/scala-asm-9.6.0-scala-1.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/compiler-interface/1.9.6/compiler-interface-1.9.6.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-reader/3.19.0/jline-reader-3.19.0.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal/3.19.0/jline-terminal-3.19.0.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal-jna/3.19.0/jline-terminal-jna-3.19.0.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/util-interface/1.9.8/util-interface-1.9.8.jar:/home/piquerez/.cache/coursier/v1/https/repo1.maven.org/maven2/net/java/dev/jna/jna/5.3.1/jna-5.3.1.jar
In which we can see that the scala3-library_3_3.3.1.jar
is in the bootclasspath. This should not be the case because the setup
configuration in scala3-compiler.json
contains "manageBootClasspath": false
.