Merge pull request #401 from eed3si9n/wip/scala2version

Fix isScalaBinaryCompatibleWith
This commit is contained in:
eugene yokota 2022-06-26 21:19:23 -04:00 committed by GitHub
commit 9c0fbb678b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -94,8 +94,10 @@ object CrossVersionUtil {
//
private[sbt] def isScalaBinaryCompatibleWith(newVersion: String, origVersion: String): Boolean = {
(newVersion, origVersion) match {
case (NonReleaseV_n("2", nMin, _, _), NonReleaseV_n("2", oMin, _, _)) =>
nMin == oMin
case (NonReleaseV_n("2", _, _, _), NonReleaseV_n("2", _, _, _)) =>
val api1 = scalaApiVersion(newVersion)
val api2 = scalaApiVersion(origVersion)
(api1.isDefined && api1 == api2) || (newVersion == origVersion)
case (ReleaseV(nMaj, nMin, _, _), ReleaseV(oMaj, oMin, _, _))
if nMaj == oMaj && nMaj.toLong >= 3 =>
nMin.toInt >= oMin.toInt

View File

@ -308,14 +308,14 @@ class CrossVersionTest extends UnitSpec {
it should "for (3.1.1, 3.1.0) return true" in {
isScalaBinaryCompatibleWith("3.1.1", "3.1.0") shouldBe true
}
it should "for (2.10.0-M1, 2.10.5) return true" in {
isScalaBinaryCompatibleWith("2.10.0-M1", "2.10.5") shouldBe true
it should "for (2.10.0-M1, 2.10.5) return false" in {
isScalaBinaryCompatibleWith("2.10.0-M1", "2.10.5") shouldBe false
}
it should "for (2.10.5, 2.10.0-M1) return true" in {
isScalaBinaryCompatibleWith("2.10.5", "2.10.0-M1") shouldBe true
it should "for (2.10.5, 2.10.0-M1) return false" in {
isScalaBinaryCompatibleWith("2.10.5", "2.10.0-M1") shouldBe false
}
it should "for (2.10.0-M1, 2.10.0-M2) return true" in {
isScalaBinaryCompatibleWith("2.10.0-M1", "2.10.0-M2") shouldBe true
it should "for (2.10.0-M1, 2.10.0-M2) return false" in {
isScalaBinaryCompatibleWith("2.10.0-M1", "2.10.0-M2") shouldBe false
}
it should "for (2.10.0-M1, 2.11.0-M1) return false" in {
isScalaBinaryCompatibleWith("2.10.0-M1", "2.11.0-M1") shouldBe false