From c6021ecdf6de316be62c071b465e04faeae9daed Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 2 Sep 2020 11:27:31 -0700 Subject: [PATCH] Allow incompatible mixed scala versions The zinc scripted project depends on all of the compiler bridges. As a result the introduction of the strict scala binary version check in f8139da1920944b8a4912fa54d898c99ae81e36a broke zinc scripted. This commit reverts to the old behavior in the non scala sandwich case. I also switched to a for comprehension instead of a pattern match because this is a rare case where I think it made the code significantly more readable. --- main/src/main/scala/sbt/Defaults.scala | 32 +++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 39120b652..3b37e8ad1 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -3470,25 +3470,19 @@ object Classpaths { val data = settingsData.value val deps = buildDependencies.value deps.classpath(ref) flatMap { dep => - val depProjIdOpt = (dep.project / projectID).get(data) - val depSVOpt = (dep.project / scalaVersion).get(data) - val depSBVOpt = (dep.project / scalaBinaryVersion).get(data) - val depCrossOpt = (dep.project / crossVersion).get(data) - (depProjIdOpt, depSVOpt, depSBVOpt, depCrossOpt) match { - case (Some(depProjId), Some(depSV), Some(depSBV), Some(depCross)) => - if (sbv == depSBV || depCross != CrossVersion.binary) - Some( - depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty) - ) - else if (isScala2Scala3Sandwich(sbv, depSBV) && depCross == CrossVersion.binary) - Some( - depProjId - .withCrossVersion(CrossVersion.constant(depSBV)) - .withConfigurations(dep.configuration) - .withExplicitArtifacts(Vector.empty) - ) - else sys.error(s"scalaBinaryVersion mismatch: expected $sbv but found ${depSBV}") - case _ => None + for { + depProjId <- (dep.project / projectID).get(data) + depSV <- (dep.project / scalaVersion).get(data) + depSBV <- (dep.project / scalaBinaryVersion).get(data) + depCross <- (dep.project / crossVersion).get(data) + } yield { + if (isScala2Scala3Sandwich(sbv, depSBV) && depCross == CrossVersion.binary) + depProjId + .withCrossVersion(CrossVersion.constant(depSBV)) + .withConfigurations(dep.configuration) + .withExplicitArtifacts(Vector.empty) + else + depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty) } } }