I am wondering if it is possible to call Dotty’s Parser directly – that is, depend on dotty as a library for my code. Unfortunately, our codebase is still on 2.13.8, which I think complicates things. I have tried to include "org.scala-lang" % "scala-compiler" % "3.1.2-RC1"
in the libraryDependencies
in sbt, but it seems to have no effect – attempts to use the parser give not found: value dotty
. It appears that different version of scala-compiler
is already present and necessary for compilation because if I add "org.scala-lang" % "scala-compiler"
to excludeDependencies
, then I get [error] java.lang.NoClassDefFoundError: scala/tools/nsc/Global
. I’m confused as to what’s going on here – my understanding is that the libraryDependencies
are the dependencies of the code being compiled, and the code used to compile that code could be totally separate, use a different classpath, etc. What am I misunderstanding here?
Looking into a little more, it looks like scala-compiler
includes the tools necessary for reflection. Am I right that if someone were to publish dotty
to a different package name (other than scala-compiler
), I would be able to depend on it without difficulty, since the package structure (dotty.
instead of scala.
) does not compete?
Oops, I think I might have missed the obvious. I need to depend on "org.scala-lang" %% "scala3-compiler" % "3.1.2-RC1"
. I’m not sure i wasn’t getting resolution error when I tried to depend on scala3-compiler with version 3.1.2
Ah, but there is no version of dotty cross-compiled for 2.13, so I will just have to make a submodule in the project compiled with Scala 3