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

Scala 3 / 2.13 backward compatibility #1641

Open
rtkaczyk opened this issue Nov 1, 2024 · 2 comments
Open

Scala 3 / 2.13 backward compatibility #1641

rtkaczyk opened this issue Nov 1, 2024 · 2 comments

Comments

@rtkaczyk
Copy link

rtkaczyk commented Nov 1, 2024

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?

@WojciechMazur
Copy link
Contributor

scala.annotation.internal is a Scala 3 specific package, it suggests that the Scala 3 standard library is missing on your classpath. Ensure that this artifact is present on classpath: https://index.scala-lang.org/scala/scala3/artifacts/scala3-library/3.3.4

@rtkaczyk
Copy link
Author

rtkaczyk commented Nov 3, 2024

Yes, I've added it as a maven dependency and it works! Thank you!

Still, feels like this might be a common use case - partially migrating larger codebases to Scala 3. It is why I'm looking into it. So I'd like to suggest for consideration adding this as an example or as a note in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants