rules_scala icon indicating copy to clipboard operation
rules_scala copied to clipboard

Scala 3 / 2.13 backward compatibility

Open rtkaczyk opened this issue 1 year ago • 2 comments
trafficstars

I'm looking into cross building Scala 2.13 / 3.3 targets and I've been playing with the 2_deps example. When I do the following tweaks:

diff --git a/examples/crossbuild/2_deps/BUILD b/examples/crossbuild/2_deps/BUILD
index ff04ca1..135fc0f 100644
--- a/examples/crossbuild/2_deps/BUILD
+++ b/examples/crossbuild/2_deps/BUILD
@@ -13,6 +13,7 @@ scala_library(
 scala_library(
     name = "lib",
     srcs = ["lib_default.scala"],
+    scala_version = "3.3.1",
 )

 scala_binary(
diff --git a/examples/crossbuild/2_deps/bin.scala b/examples/crossbuild/2_deps/bin.scala
index f038de2..d70708c 100644
--- a/examples/crossbuild/2_deps/bin.scala
+++ b/examples/crossbuild/2_deps/bin.scala
@@ -1,3 +1,3 @@
 object C extends App {
-  println("Hello, world")
+  println("Hello, world: " + new B)
 }

then bin213 fails to build:

error: error while loading B, Missing dependency 'Add -Ytasty-reader to scalac options to parse the TASTy in bazel-out/darwin_arm64-fastbuild/bin/2_deps/lib.jar(deps/B.class)', required by bazel-out/darwin_arm64-fastbuild/bin/2_deps/lib.jar(deps/B.class)
2_deps/bin.scala:4: error: deps.B does not have a constructor
  println("Hello, world: " + new B)
                             ^

Adding -Ytasty-reader doesn't help, produces a different error:

2_deps/bin.scala:2: error: could not find package scala.annotation.internal whilst reading annotation of package <empty>; perhaps it is missing from the classpath.
  println("Hello, world: " + new B)
                                 ^

So, is 3 ← 2.13 backward compatibility not supported / broken, or am I missing something?

rtkaczyk avatar Nov 01 '24 07:11 rtkaczyk