Skip to content

Commit 33c0ce0

Browse files
committed
sbt-dotty: Make withDottyCompat work with dotty dependencies
Now that we add dotty-library to libraryDependencies, we need to be more careful to make this work: libraryDependencies ~= (_.map(_.withDottyCompat(scalaVersion.value))) This is needed to keep the community-build working.
1 parent 0162bf4 commit 33c0ce0

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,26 @@ object DottyPlugin extends AutoPlugin {
7272
* with Dotty this will change the cross-version to a Scala 2.x one. This
7373
* works because Dotty is currently retro-compatible with Scala 2.x.
7474
*
75-
* NOTE: Dotty's retro-compatibility with Scala 2.x will be dropped before
76-
* Dotty is released, you should not rely on it.
75+
* NOTE: As a special-case, the cross-version of dotty-library, dotty-compiler and
76+
* dotty will never be rewritten because we know that they're Dotty-only.
77+
* This makes it possible to do something like:
78+
* {{{
79+
* libraryDependencies ~= (_.map(_.withDottyCompat(scalaVersion.value)))
80+
* }}}
7781
*/
78-
def withDottyCompat(scalaVersion: String): ModuleID =
79-
moduleID.crossVersion match {
80-
case _: librarymanagement.Binary if scalaVersion.startsWith("0.") =>
81-
moduleID.cross(CrossVersion.constant("2.12"))
82-
case _ =>
83-
moduleID
82+
def withDottyCompat(scalaVersion: String): ModuleID = {
83+
val name = moduleID.name
84+
if (name == "dotty" || name == "dotty-library" || name == "dotty-compiler") {
85+
moduleID.crossVersion match {
86+
case _: librarymanagement.Binary if scalaVersion.startsWith("0.") =>
87+
moduleID.cross(CrossVersion.constant("2.12"))
88+
case _ =>
89+
moduleID
90+
}
8491
}
92+
else
93+
moduleID
94+
}
8595
}
8696
}
8797

0 commit comments

Comments
 (0)