Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Bump version of sbt to 1.9.3" to LTS #19143

Merged
merged 4 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final case class SbtCommunityProject(
case Some(ivyHome) => List(s"-Dsbt.ivy.home=$ivyHome")
case _ => Nil
extraSbtArgs ++ sbtProps ++ List(
"-sbt-version", "1.9.0",
"-sbt-version", "1.9.3",
"-Dsbt.supershell=false",
s"-Ddotty.communitybuild.dir=$communitybuildDir",
s"--addPluginSbtFile=$sbtPluginFilePath"
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ object Dependencies {
"com.vladsch.flexmark" % "flexmark-ext-yaml-front-matter" % flexmarkVersion,
)

val compilerInterface = "org.scala-sbt" % "compiler-interface" % "1.9.0"
val compilerInterface = "org.scala-sbt" % "compiler-interface" % "1.9.3"
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.0
sbt.version=1.9.3
19 changes: 17 additions & 2 deletions sbt-bridge/src/dotty/tools/xsbt/CompilerBridgeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,23 @@ synchronized public void run(VirtualFile[] sources, AnalysisCallback callback, L
doCompile(compiler, sourcesBuffer.toList(), context);

for (xsbti.Problem problem: delegate.problems()) {
callback.problem(problem.category(), problem.position(), problem.message(), problem.severity(),
true);
try {
AnalysisCallback2 callback2 = (AnalysisCallback2)callback;
callback2.problem2(
problem.category(),
problem.position(),
problem.message(),
problem.severity(),
true, // reported
problem.rendered(),
problem.diagnosticCode(),
problem.diagnosticRelatedInformation(),
problem.actions()
);
} catch (NoClassDefFoundError e) {
callback.problem(problem.category(), problem.position(), problem.message(), problem.severity(),
true);
}
}
} else {
delegate.printSummary();
Expand Down
2 changes: 1 addition & 1 deletion sbt-bridge/test/xsbt/DependencySpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@ class DependencySpecification {
compilerForTesting.extractDependenciesFromSrcs(srcA, srcB, srcC, srcD)
classDependencies
}
}
}
147 changes: 110 additions & 37 deletions sbt-bridge/test/xsbti/TestCallback.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Copied from https://github.com/sbt/sbt/blob/0.13/interface/src/test/scala/xsbti/TestCallback.scala */
// Taken from https://github.com/sbt/zinc/blob/aa1c04f445092e87f76aaceee4da61ea0724419e/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala
package xsbti

import java.io.File
Expand All @@ -8,49 +8,95 @@ import xsbti.VirtualFileRef
import xsbti.api.ClassLike
import xsbti.api.DependencyContext
import DependencyContext._
import java.util.EnumSet
import java.{util => ju}
import ju.Optional

class TestCallback extends AnalysisCallback2 {
case class TestUsedName(name: String, scopes: ju.EnumSet[UseScope])

class TestCallback extends AnalysisCallback
{
case class TestUsedName(name: String, scopes: EnumSet[UseScope])
val classDependencies = new ArrayBuffer[(String, String, DependencyContext)]
val binaryDependencies = new ArrayBuffer[(Path, String, String, VirtualFileRef, DependencyContext)]
val products = new ArrayBuffer[(VirtualFileRef, Path)]
val usedNamesAndScopes = scala.collection.mutable.Map.empty[String, Set[TestUsedName]].withDefaultValue(Set.empty)
val classNames = scala.collection.mutable.Map.empty[VirtualFileRef, Set[(String, String)]].withDefaultValue(Set.empty)
val apis: scala.collection.mutable.Map[VirtualFileRef, Seq[ClassLike]] = scala.collection.mutable.Map.empty
val binaryDependencies =
new ArrayBuffer[(Path, String, String, VirtualFileRef, DependencyContext)]
val productClassesToSources =
scala.collection.mutable.Map.empty[Path, VirtualFileRef]
val usedNamesAndScopes = scala.collection.mutable.Map
.empty[String, Set[TestUsedName]]
.withDefaultValue(Set.empty)
val classNames = scala.collection.mutable.Map
.empty[VirtualFileRef, Set[(String, String)]]
.withDefaultValue(Set.empty)
val apis: scala.collection.mutable.Map[VirtualFileRef, Seq[ClassLike]] =
scala.collection.mutable.Map.empty

def usedNames = usedNamesAndScopes.view.mapValues(_.map(_.name)).toMap

override def startSource(source: File): Unit = ???
override def startSource(source: VirtualFile): Unit = {
assert(!apis.contains(source), s"startSource can be called only once per source file: $source")
assert(
!apis.contains(source),
s"startSource can be called only once per source file: $source"
)
apis(source) = Seq.empty
}

override def binaryDependency(binary: File, name: String, fromClassName: String, source: File, context: DependencyContext): Unit = ???
override def binaryDependency(binary: Path, name: String, fromClassName: String, source: VirtualFileRef, context: DependencyContext): Unit = {
override def binaryDependency(
binary: File,
name: String,
fromClassName: String,
source: File,
context: DependencyContext
): Unit = ???
override def binaryDependency(
binary: Path,
name: String,
fromClassName: String,
source: VirtualFileRef,
context: DependencyContext
): Unit = {
binaryDependencies += ((binary, name, fromClassName, source, context))
}

override def generatedNonLocalClass(source: File, module: File, binaryClassName: String, srcClassName: String): Unit = ???
override def generatedNonLocalClass(source: VirtualFileRef, module: Path, binaryClassName: String, srcClassName: String): Unit = {
products += ((source, module))
classNames(source) += ((srcClassName, binaryClassName))
override def generatedNonLocalClass(
source: File,
module: File,
binaryClassName: String,
srcClassName: String
): Unit = ???

override def generatedNonLocalClass(
sourceFile: VirtualFileRef,
classFile: Path,
binaryClassName: String,
srcClassName: String
): Unit = {
productClassesToSources += ((classFile, sourceFile))
classNames(sourceFile) += ((srcClassName, binaryClassName))
()
}

override def generatedLocalClass(source: File, module: File): Unit = ???
override def generatedLocalClass(source: VirtualFileRef, module: Path): Unit = {
products += ((source, module))
override def generatedLocalClass(
sourceFile: VirtualFileRef,
classFile: Path
): Unit = {
productClassesToSources += ((classFile, sourceFile))
()
}

override def classDependency(onClassName: String, sourceClassName: String, context: DependencyContext): Unit = {
if (onClassName != sourceClassName) classDependencies += ((onClassName, sourceClassName, context))
override def classDependency(
onClassName: String,
sourceClassName: String,
context: DependencyContext
): Unit = {
if (onClassName != sourceClassName)
classDependencies += ((onClassName, sourceClassName, context))
}

override def usedName(className: String, name: String, scopes: EnumSet[UseScope]): Unit = {
override def usedName(
className: String,
name: String,
scopes: ju.EnumSet[UseScope]
): Unit = {
usedNamesAndScopes(className) += TestUsedName(name, scopes)
}

Expand All @@ -59,7 +105,24 @@ class TestCallback extends AnalysisCallback
apis(source) = classApi +: apis(source)
}

override def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean): Unit = ()
override def problem(
category: String,
pos: xsbti.Position,
message: String,
severity: xsbti.Severity,
reported: Boolean
): Unit = ()
override def problem2(
category: String,
pos: Position,
msg: String,
severity: Severity,
reported: Boolean,
rendered: Optional[String],
diagnosticCode: Optional[xsbti.DiagnosticCode],
diagnosticRelatedInformation: ju.List[xsbti.DiagnosticRelatedInformation],
actions: ju.List[xsbti.Action]
): Unit = ()
override def dependencyPhaseCompleted(): Unit = ()
override def apiPhaseCompleted(): Unit = ()
override def enabled(): Boolean = true
Expand All @@ -68,29 +131,39 @@ class TestCallback extends AnalysisCallback
override def mainClass(source: VirtualFileRef, className: String): Unit = ???

override def classesInOutputJar(): java.util.Set[String] = ???
override def getPickleJarPair(): java.util.Optional[xsbti.T2[Path, Path]] = ???
override def getPickleJarPair(): java.util.Optional[xsbti.T2[Path, Path]] =
???
override def isPickleJava(): Boolean = ???
}

object TestCallback {
case class ExtractedClassDependencies(memberRef: Map[String, Set[String]],
inheritance: Map[String, Set[String]],
localInheritance: Map[String, Set[String]])
case class ExtractedClassDependencies(
memberRef: Map[String, Set[String]],
inheritance: Map[String, Set[String]],
localInheritance: Map[String, Set[String]]
)
object ExtractedClassDependencies {
def fromPairs(
memberRefPairs: collection.Seq[(String, String)],
inheritancePairs: collection.Seq[(String, String)],
localInheritancePairs: collection.Seq[(String, String)]
): ExtractedClassDependencies = {
ExtractedClassDependencies(pairsToMultiMap(memberRefPairs),
memberRefPairs: collection.Seq[(String, String)],
inheritancePairs: collection.Seq[(String, String)],
localInheritancePairs: collection.Seq[(String, String)]
): ExtractedClassDependencies = {
ExtractedClassDependencies(
pairsToMultiMap(memberRefPairs),
pairsToMultiMap(inheritancePairs),
pairsToMultiMap(localInheritancePairs))
pairsToMultiMap(localInheritancePairs)
)
}

private def pairsToMultiMap[A, B](pairs: collection.Seq[(A, B)]): Map[A, Set[B]] = {
pairs.groupBy(_._1).view.mapValues(values => values.map(_._2).toSet)
.toMap.withDefaultValue(Set.empty)
private def pairsToMultiMap[A, B](
pairs: collection.Seq[(A, B)]
): Map[A, Set[B]] = {
pairs
.groupBy(_._1)
.view
.mapValues(values => values.map(_._2).toSet)
.toMap
.withDefaultValue(Set.empty)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.0
sbt.version=1.9.3
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.0
sbt.version=1.9.3