Skip to content

Commit

Permalink
Merge branch 'develop' into merge-1-x
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Oct 15, 2024
2 parents 9e7e953 + 41dd74e commit e145771
Show file tree
Hide file tree
Showing 35 changed files with 474 additions and 230 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ jobs:
if: ${{ matrix.jobtype == 2 }}
shell: bash
run: |
sbt -v -Dfile.encoding=UTF-8 -Dsbt.supershell=never "Test/compile" "crossTestBridges" "zincRoot/test"
# "zincScripted/Test/run"
sbt -v -Dfile.encoding=UTF-8 -Dsbt.supershell=never "Test/compile" "crossTestBridges" "zincRoot/test" "scripted"
- name: Build and test (3)
if: ${{ matrix.jobtype == 3 }}
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion bin/run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sbt -Dfile.encoding=UTF-8 \
doc \
crossTestBridges \
test \
# scripted
scripted
11 changes: 3 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ lazy val compilerInterface = (projectMatrix in internalPath / "compiler-interfac
exclude[InheritedNewAbstractMethodProblem]("xsbti.InteractiveConsoleInterface.close"),
),
)
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaPartialVersion(scala212))
.jvmPlatform(autoScalaLibrary = false)
.configure(addSbtUtilInterface(_))

Expand Down Expand Up @@ -532,8 +531,7 @@ lazy val compilerBridgeTest = (projectMatrix in internalPath / "compiler-bridge-
Test / javaOptions += s"-Dzinc.build.compilerbridge.scalaVersion=${scala213}",
publish / skip := true,
)
.defaultAxes(VirtualAxis.jvm, VirtualAxis.scalaPartialVersion(scala212))
.jvmPlatform(scalaVersions = scala212_213)
.jvmPlatform(scalaVersions = scala3_only)

val scalaPartialVersion = Def.setting(CrossVersion.partialVersion(scalaVersion.value))

Expand Down Expand Up @@ -654,9 +652,6 @@ lazy val zincScripted = (projectMatrix in internalPath / "zinc-scripted")
conflictWarning := ConflictWarning.disable,
)
.jvmPlatform(scalaVersions = scala3_only)
.configure(
_.dependsOn(compilerBridge210, compilerBridge211, compilerBridge212, compilerBridge213)
)
.configure(addSbtUtilScripted)

lazy val zincScripted3 = zincScripted.jvm(scala3)
Expand All @@ -678,7 +673,7 @@ val publishBridges = taskKey[Unit]("")
val crossTestBridges = taskKey[Unit]("")

publishBridges := Def.task(()).dependsOn(bridges: _*).value
crossTestBridges := (compilerBridgeTest.jvm(scala213) / Test / test).dependsOn(publishBridges).value
crossTestBridges := (compilerBridgeTest.jvm(scala3) / Test / test).dependsOn(publishBridges).value

addCommandAlias(
"runBenchmarks", {
Expand All @@ -704,4 +699,4 @@ def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
scriptedBufferLog.value,
scriptedCompileToJar.value,
)
}
}.dependsOn(publishBridges)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object GlobalBenchmarkSetup {

def runSetup(setupDir: File, pattern: String): (Int, String) = {
val projectsPreparation = projects
.filterKeys { _.matches(pattern) }
.view.filterKeys { _.matches(pattern) }
.map { case (_, project) =>
val benchmark = new ZincBenchmark(project)
project -> benchmark.writeSetup(new File(setupDir, project.repo))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private[xsbt] object ZincBenchmark {
| // Resolve project dynamically to avoid name clashes/overloading
| val project = LocalProject("$sbtProject")
| Def.task {
| val file = new File("${outputFile.getAbsolutePath.replaceAllLiterally("\\", "/")}")
| val file = new File("${outputFile.getAbsolutePath.replace("\\", "/")}")
| val rawSources = (sources in Compile in project).value
| val sourcesLine = rawSources.map(_.getCanonicalPath).mkString(" ")
| val rawClasspath = (dependencyClasspath in Compile in project).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object ClasspathUtil {

/** Returns all entries in 'classpath' that correspond to a compiler plugin.*/
private[sbt] def compilerPlugins(classpath: Seq[Path], isDotty: Boolean): Iterable[Path] = {
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
val loader = new URLClassLoader(toURLs(classpath).toArray)
val metaFile = if (isDotty) "plugin.properties" else "scalac-plugin.xml"
loader.getResources(metaFile).asScala.toList.flatMap(asFile(true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ final class AnalyzingCompiler(
log: xLogger
): Unit = {
val progress = if (progressOpt.isPresent) progressOpt.get else IgnoreProgress
val cp = classpath.map(converter.toPath)
val arguments = compArgs.makeArguments(Nil, cp, options).toArray
val cp = classpath.map(converter.toPath).toIndexedSeq
val arguments = compArgs.makeArguments(Nil, cp, options.toIndexedSeq).toArray
// hold reference to compiler bridge class loader to prevent its being evicted
// from the compiler cache (sbt/zinc#914)
val loader = getCompilerLoader(log)
Expand Down Expand Up @@ -454,7 +454,7 @@ object AnalyzingCompiler {
val scalaLibraryJars = compiler.scalaInstance.libraryJars
val restClasspath = xsbtiJars.toSeq ++ sourceJars
val classpath = scalaLibraryJars.map(_.toPath) ++ restClasspath
compiler(sourceFiles, classpath, outputDirectory.toPath, "-nowarn" :: Nil)
compiler(sourceFiles, classpath.toIndexedSeq, outputDirectory.toPath, "-nowarn" :: Nil)

val end = (System.currentTimeMillis - start) / 1000.0
log.info(s" Compilation completed in ${end}s.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ class FilteredReporter(
filters.exists(f => f(value).booleanValue())

severity != Severity.Error && (
(pos.sourceFile.isPresent && isFiltered(fileFilters, pos.sourceFile.get.toPath)) ||
(isFiltered(msgFilters, msg))
(pos.sourceFile.isPresent && isFiltered(
fileFilters.toIndexedSeq,
pos.sourceFile.get.toPath
)) ||
(isFiltered(msgFilters.toIndexedSeq, msg))
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object ForkedJava {
}
}
// javac's argument file seems to allow naive space escaping with quotes. escaping a quote with a backslash does not work
private def escapeSpaces(s: String): String = '\"' + normalizeSlash(s) + '\"'
private def escapeSpaces(s: String): String = s"\"${normalizeSlash(s)}\""
private def normalizeSlash(s: String) = s.replace(File.separatorChar, '/')

/** create the executable name for java */
Expand All @@ -100,7 +100,15 @@ final class ForkedJavaCompiler(javaHome: Option[Path]) extends XJavaCompiler {
reporter: Reporter,
log: XLogger
): Boolean =
ForkedJava.launch(javaHome, "javac", sources, options, output, log, reporter)
ForkedJava.launch(
javaHome,
"javac",
sources.toIndexedSeq,
options.toIndexedSeq,
output,
log,
reporter,
)
}
final class ForkedJavadoc(javaHome: Option[Path]) extends XJavadoc {
def run(
Expand All @@ -111,5 +119,13 @@ final class ForkedJavadoc(javaHome: Option[Path]) extends XJavadoc {
reporter: Reporter,
log: XLogger
): Boolean =
ForkedJava.launch(javaHome, "javadoc", sources, options, output, log, reporter)
ForkedJava.launch(
javaHome,
"javadoc",
sources.toIndexedSeq,
options.toIndexedSeq,
output,
log,
reporter,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ object LocalJava {
): Int = {
(javadocTool, standardDocletClass) match {
case (Some(m), Some(clz)) =>
import scala.jdk.CollectionConverters._
val task = m.getTask(
out,
null,
Expand Down Expand Up @@ -290,7 +289,6 @@ final class LocalJavaCompiler(compiler: javax.tools.JavaCompiler) extends XJavaC
log0: XLogger
): Boolean = {
val log: Logger = log0
import collection.JavaConverters._
val logger = new LoggerWriter(log)
val logWriter = new PrintWriter(logger)
log.debug("Attempting to call " + compiler + " directly...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class JavaCompilerSpec extends UnitSpec with Diagrams {
val leftAPI = compileWithPrimitive(leftType, left)
val rightAPI = compileWithPrimitive(rightType, right)
assert(leftAPI.size == rightAPI.size)
assert(((leftAPI, rightAPI).zipped forall SameAPI.apply) == (left == right))
assert(leftAPI.lazyZip(rightAPI).forall(SameAPI.apply) == (left == right))
()
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ final case class TraitPrivateMembersModified(modified: String) extends APIChange
final case class ModifiedNames(names: Set[UsedName]) {
def in(scope: UseScope): Set[UsedName] = names.filter(_.scopes.contains(scope))

import collection.JavaConverters._
private lazy val lookupMap: Set[(String, UseScope)] =
names.flatMap(n => n.scopes.asScala.map(n.name -> _))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sealed trait FileValueCache[T] {
object FileValueCache {
def apply[T](f: Path => T): FileValueCache[T] = make(Stamper.forLastModifiedP)(f)
def make[T](stamp: Path => XStamp)(f: Path => T): FileValueCache[T] =
new FileValueCache0[T](stamp, f)
new FileValueCache0[T](stamp, f)(Equiv.universal)
}

private[this] final class FileValueCache0[T](getStamp: Path => XStamp, make: Path => T)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ object Incremental {
earlyOutput,
progress,
log
)
)(Equiv.universal)
} catch {
case _: xsbti.CompileCancelled =>
log.info("Compilation has been cancelled")
Expand Down Expand Up @@ -371,7 +371,7 @@ object Incremental {
)
}
}
val pickleJava = isPickleJava(scalacOptions)
val pickleJava = isPickleJava(scalacOptions.toIndexedSeq)
val hasModified = initialInvClasses.nonEmpty || initialInvSources0.nonEmpty
if (javaSources.nonEmpty && earlyOutput.isDefined && !pickleJava) {
log.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Locate {
case x => x
}
}
def find[S](name: String, gets: Stream[String => Either[Boolean, S]]): Either[Boolean, S] =
def find[S](name: String, gets: LazyList[String => Either[Boolean, S]]): Either[Boolean, S] =
find[S](name, gets.iterator)

/**
Expand Down Expand Up @@ -102,7 +102,7 @@ object Locate {
}

private class JarDefinesClass(entry: Path) extends DefinesClass {
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
private val entries = {
val jar =
try {
Expand Down Expand Up @@ -148,6 +148,6 @@ object Locate {
def components(className: String): (Seq[String], String) = {
assume(!className.isEmpty)
val parts = className.split("\\.")
if (parts.length == 1) (Nil, parts(0)) else (parts.init, parts.last)
if (parts.length == 1) (Nil, parts(0)) else (parts.init.toIndexedSeq, parts.last)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ object SourceInfos {

def merge1(info1: SourceInfo, info2: SourceInfo) = {
makeInfo(
mergeProblems(info1.getReportedProblems, info2.getReportedProblems),
mergeProblems(info1.getUnreportedProblems, info2.getUnreportedProblems),
(info1.getMainClasses ++ info2.getMainClasses).distinct,
mergeProblems(info1.getReportedProblems.toIndexedSeq, info2.getReportedProblems.toIndexedSeq),
mergeProblems(
info1.getUnreportedProblems.toIndexedSeq,
info2.getUnreportedProblems.toIndexedSeq,
),
(info1.getMainClasses ++ info2.getMainClasses).distinct.toIndexedSeq,
)
}

Expand Down Expand Up @@ -98,8 +101,8 @@ private final class MSourceInfos(val allInfos: Map[VirtualFileRef, SourceInfo])
allInfos.getOrElse(file, SourceInfos.emptyInfo)

override def getAllSourceInfos: java.util.Map[VirtualFileRef, SourceInfo] = {
import scala.collection.JavaConverters.mapAsJavaMapConverter
mapAsJavaMapConverter(allInfos).asJava
import scala.jdk.CollectionConverters._
allInfos.asJava
}
}

Expand Down
14 changes: 5 additions & 9 deletions internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import xsbti.{ FileConverter, VirtualFile, VirtualFileRef }
import xsbti.compile.analysis.{ ReadStamps, Stamp => XStamp }

import scala.collection.immutable.TreeMap
import scala.jdk.CollectionConverters._
import scala.util.matching.Regex

/**
Expand Down Expand Up @@ -241,7 +242,6 @@ object Stamper {
converter: FileConverter,
getStamp: VirtualFileRef => XStamp
): VirtualFileRef => XStamp = { (key: VirtualFileRef) =>
import scala.collection.JavaConverters._
val p = converter.toPath(key)
val ts =
try IO.getModifiedTimeOrZero(p.toFile)
Expand Down Expand Up @@ -320,13 +320,12 @@ private class MStamps(
val libraries: Map[VirtualFileRef, XStamp]
) extends Stamps {

import scala.collection.JavaConverters.mapAsJavaMapConverter
override def getAllLibraryStamps: util.Map[VirtualFileRef, XStamp] =
mapAsJavaMapConverter(libraries).asJava
libraries.asJava
override def getAllProductStamps: util.Map[VirtualFileRef, XStamp] =
mapAsJavaMapConverter(products).asJava
products.asJava
override def getAllSourceStamps: util.Map[VirtualFileRef, XStamp] =
mapAsJavaMapConverter(sources).asJava
sources.asJava

def allSources: collection.Set[VirtualFileRef] = sources.keySet
def allLibraries: collection.Set[VirtualFileRef] = libraries.keySet
Expand Down Expand Up @@ -407,7 +406,6 @@ private class InitialStamps(
) extends ReadStamps {
import collection.concurrent.Map
import java.util.concurrent.ConcurrentHashMap
import scala.collection.JavaConverters._

// cached stamps for files that do not change during compilation
private val libraries: Map[VirtualFileRef, XStamp] = new ConcurrentHashMap().asScala
Expand All @@ -431,7 +429,6 @@ private class TimeWrapBinaryStamps(
) extends ReadStamps {
import collection.concurrent.Map
import java.util.concurrent.ConcurrentHashMap
import scala.collection.JavaConverters._

// cached stamps for files that do not change during compilation
private val libraries: Map[VirtualFileRef, (Long, XStamp)] = new ConcurrentHashMap().asScala
Expand Down Expand Up @@ -460,8 +457,7 @@ private class UncachedStamps(
libStamp: VirtualFileRef => XStamp
) extends ReadStamps {
import VirtualFileUtil._
import scala.collection.JavaConverters.mapAsJavaMapConverter
val eSt = mapAsJavaMapConverter(TreeMap.empty[VirtualFileRef, XStamp]).asJava
val eSt = TreeMap.empty[VirtualFileRef, XStamp].asJava

override def getAllLibraryStamps: util.Map[VirtualFileRef, XStamp] = eSt
override def getAllSourceStamps: util.Map[VirtualFileRef, XStamp] = eSt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object UsedName {

private def escapeControlChars(name: String) = {
if (name.indexOf('\n') > 0) // optimize for common case to regex overhead
name.replaceAllLiterally("\n", "\u26680A")
name.replace("\n", "\u26680A")
else
name
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e145771

Please sign in to comment.