-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Issue spotted in Scala Native scripted tests which tests compatibility between different combinations of Scala 2.13 and Scala 3 projects: https://github.com/scala-native/scala-native/tree/0162c3c0c3ef904f6ca4e9de6cd0bee150e347f3/scripted-tests/scala3/cross-version-compat
Scala Native in Scala 2.13 uses macros in one of the core components thus adds org.scala-lang:scala-reflect to the dependencies. There is no such dependency in Scala 3 variant of these components. For historical reasons for long time some Scala 3 dependenent on Scala 2.13 artifacts (containg Scala 2.13 std lib)
If we define Scala 2.13 project which uses scala-reflect and depends on Scala 3 project without any dependencies (beside stdlib) the scala-reflect version would be evicted to 3.8.0 which does not exist.
// Full code available in .zip
val scala3Version = "3.8.0"
val scala213Version = "2.13.18"
inThisBuild(
Seq(
scalaVersion := scala3Version,
crossScalaVersions := Seq(scala3Version, scala213Version),
version := "0.1.0-SNAPSHOT",
organization := "org.scala-native.test",
publishMavenStyle := true
)
)
def commonSettings = Def.settings(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Seq("-Ytasty-reader")
case _ => Nil
}
},
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) =>
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
case _ => Nil
}
}
)
lazy val base = project
.in(file("base"))
// works
lazy val projectA = project
.in(file("project-A"))
.settings(
libraryDependencies += organization.value %% (base / normalizedName).value % version.value
)
// works
lazy val projectB = project
.in(file("project-B"))
.settings(
commonSettings,
libraryDependencies += (organization.value %% (base / normalizedName).value % version.value)
.cross(CrossVersion.for3Use2_13)
)
// fails for 2.13, works for 3.8
lazy val projectC = project
.in(file("project-C"))
.settings(
commonSettings,
libraryDependencies += (organization.value %% (base / normalizedName).value % version.value)
.cross(CrossVersion.for2_13Use3)
)
steps
Ready to use project
repro.zip
Run +base/publishLocal;+projectC/compile
Alternatively run +base/publishLocal;+projectA/compile;+projectB/compile;+projectC/compile for full test (including working scenarios)
problem
info] Setting Scala version to 2.13.18 on 5 projects.
[info] Reapplying settings...
[info] set current project to sandbox (in build file:/Users/wmazur/projects/scala/sandbox/)
[info] Updating projectc_2.13
[info] Resolved projectc_2.13 dependencies
[warn]
[warn] Note: Unresolved dependencies path:
[error] stack trace is suppressed; run last projectC / update for the full output
[error] (projectC / update) sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-reflect:3.8.0
[error] Not found
[error] Not found
[error] not found: /Users/wmazur/.ivy2/local/org.scala-lang/scala-reflect/3.8.0/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/3.8.0/scala-reflect-3.8.0.pom
[error] Total time: 0 s, completed Jan 14, 2026, 8:27:04 PM
expectation
notes
I have not tested if this issue does also exist if don't use locally published artifacts (I remember there some issue related to that and raised during 3.8.0-RC period)
scala-reflect:3.8.0 is not present in the dependencyTree
> ++2.13.18; projectC/dependencyTree
[info] Setting Scala version to 2.13.18 on 5 projects.
[info] Reapplying settings...
[info] set current project to sandbox (in build file:/Users/wmazur/projects/scala/sandbox/)
[info] org.scala-native.test:projectc_2.13:0.1.0-SNAPSHOT [S]
[info] +-org.scala-lang:scala-reflect:2.13.18 [S]
[info] +-org.scala-native.test:base_3:0.1.0-SNAPSHOT
[info] +-org.scala-lang:scala3-library_3:3.8.0 [S]
[info] PS. The compilation in this setup should most likely fails becouse Scala 2.13.18 does not support consuming Scala 3.8 Tasty yet via -Xtasty-reader, but that's not the related to this issue.