Merge pull request #352 from eed3si9n/wip/match_error

Fixes match error when using withDottyCompat
This commit is contained in:
eugene yokota 2020-12-19 17:32:40 -05:00 committed by GitHub
commit 7547f67294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 5 deletions

View File

@ -98,12 +98,25 @@ object EvictionWarningOptions {
lazy val defaultGuess: Function1[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] =
guessSbtOne orElse guessSecondSegment orElse guessSemVer orElse guessFalse
private def isNameScalaSuffixed(name: String): Boolean =
name.contains("_2.") || name.contains("_3") || name.contains("_4")
/** A partial function that checks if given m2 is suffixed, and use pvp to evaluate. */
lazy val guessSecondSegment
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
case (m1, Some(m2), Some(scalaModuleInfo))
if m2.name.endsWith("_" + scalaModuleInfo.scalaFullVersion) || m2.name.endsWith(
"_" + scalaModuleInfo.scalaBinaryVersion
) =>
case (m1, Some(m2), Some(_)) if isNameScalaSuffixed(m2.name) =>
(m1.revision, m2.revision) match {
case (VersionNumber(ns1, ts1, es1), VersionNumber(ns2, ts2, es2)) =>
VersionNumber.SecondSegment
.isCompatible(VersionNumber(ns1, ts1, es1), VersionNumber(ns2, ts2, es2))
case _ => false
}
}
/** A partial function that checks two versions match pvp. */
private[sbt] lazy val evalPvp
: PartialFunction[(ModuleID, Option[ModuleID], Option[ScalaModuleInfo]), Boolean] = {
case (m1, Some(m2), _) =>
(m1.revision, m2.revision) match {
case (VersionNumber(ns1, ts1, es1), VersionNumber(ns2, ts2, es2)) =>
VersionNumber.SecondSegment

View File

@ -283,6 +283,24 @@ object EvictionWarningSpec extends BaseIvySpecification {
)
}
test("Comparing 2.13 libraries with pvp under Scala 3.0.0-M3 should work") {
val m1 = "org.scodec" % "scodec-bits_2.13" % "1.1.21"
val m2 = "org.scodec" % "scodec-bits_2.13" % "1.1.22"
assert(
EvictionWarningOptions
.evalPvp((m1, Option(m2), Option(dummyScalaModuleInfo("3.0.0-M3"))))
)
}
test("Comparing 2.13 libraries with guessSecondSegment under Scala 3.0.0-M3 should work") {
val m1 = "org.scodec" % "scodec-bits_2.13" % "1.1.21"
val m2 = "org.scodec" % "scodec-bits_2.13" % "1.1.22"
assert(
EvictionWarningOptions
.guessSecondSegment((m1, Option(m2), Option(dummyScalaModuleInfo("3.0.0-M3"))))
)
}
def akkaActor214 =
ModuleID("com.typesafe.akka", "akka-actor", "2.1.4").withConfigurations(Some("compile")) cross CrossVersion.binary
def akkaActor230 =

View File

@ -1 +1 @@
sbt.version=1.4.2
sbt.version=1.4.5