mirror of https://github.com/sbt/sbt.git
Fail the build if 2.13 scalaVersion < scala artifact on classpath
When expanding a macro compiled against a new Scala library, the runtime classpath of the compiler should not contain an older library. Otherwise a NoSuchMethodException can occur. A similar issue is present when running the Scala repl through sbt. An input line compiled against a new library could fail to run if the repl's runtime classpath is on an old version.
This commit is contained in:
parent
35bc07bd9e
commit
4c74358707
|
|
@ -1150,6 +1150,23 @@ object Defaults extends BuildCommon {
|
|||
.configuration(Configurations.ScalaTool)
|
||||
.getOrElse(sys.error(noToolConfiguration(managedScalaInstance.value)))
|
||||
|
||||
if (Classpaths.isScala213(sv)) {
|
||||
for {
|
||||
compileReport <- fullReport.configuration(Configurations.Compile)
|
||||
libName <- ScalaArtifacts.Artifacts
|
||||
} {
|
||||
for (lib <- compileReport.modules.find(_.module.name == libName)) {
|
||||
val libVer = lib.module.revision
|
||||
if (VersionNumber(sv).matchesSemVer(SemanticSelector(s"<$libVer")))
|
||||
sys.error(
|
||||
s"""`${name.value}/scalaVersion` needs to be upgraded to $libVer. To support backwards-only
|
||||
|binary compatibility (SIP-51), the Scala compiler cannot be older than $libName on the
|
||||
|dependency classpath. See `${name.value}/evicted` why $libName was upgraded from $sv to $libVer.
|
||||
|""".stripMargin
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
def file(id: String): File = {
|
||||
val files = for {
|
||||
m <- toolReport.modules if m.module.name.startsWith(id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue