From 5a41ce63f6935533e9330a10ae506a259783feb3 Mon Sep 17 00:00:00 2001 From: friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Sun, 13 Oct 2024 15:16:37 -0700 Subject: [PATCH 1/5] Clean compile warnings --- .../src/test/scala/xsbt/ZincBenchmark.scala | 2 +- .../sbt/internal/inc/AnalyzingCompiler.scala | 6 +++--- .../sbt/internal/inc/FilteredReporter.scala | 7 +++++-- .../sbt/internal/inc/javac/ForkedJava.scala | 20 +++++++++++++++++-- .../sbt/internal/inc/javac/LocalJava.scala | 2 -- .../main/scala/sbt/internal/inc/Changes.scala | 1 - .../sbt/internal/inc/FileValueCache.scala | 2 +- .../scala/sbt/internal/inc/Incremental.scala | 4 ++-- .../main/scala/sbt/internal/inc/Locate.scala | 4 ++-- .../scala/sbt/internal/inc/SourceInfo.scala | 15 ++++++++------ .../main/scala/sbt/internal/inc/Stamp.scala | 18 +++++++---------- .../scala/sbt/internal/inc/UsedName.scala | 2 +- .../consistent/ConsistentAnalysisFormat.scala | 4 ++-- .../inc/text/TextAnalysisFormat.scala | 18 ++++++++++++++--- .../scala/sbt/inc/AnalysisGenerators.scala | 2 +- .../scala/sbt/internal/inc/IncHandler.scala | 2 +- .../inc/IncrementalCompilerImpl.scala | 18 ++++++++--------- .../internal/inc/MixedAnalyzingCompiler.scala | 12 ++++++----- .../inc/javac/AnalyzingJavaCompiler.scala | 2 +- .../sbt/inc/cached/CachedHashingSpec.scala | 6 +++--- 20 files changed, 88 insertions(+), 59 deletions(-) diff --git a/internal/zinc-benchmarks/src/test/scala/xsbt/ZincBenchmark.scala b/internal/zinc-benchmarks/src/test/scala/xsbt/ZincBenchmark.scala index 2c411579f6..72e6dfeb30 100644 --- a/internal/zinc-benchmarks/src/test/scala/xsbt/ZincBenchmark.scala +++ b/internal/zinc-benchmarks/src/test/scala/xsbt/ZincBenchmark.scala @@ -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 diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala index 1f2d57fd6a..b9f0cc9b05 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/AnalyzingCompiler.scala @@ -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) @@ -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.") diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/FilteredReporter.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/FilteredReporter.scala index 4c4856150d..2312de34a5 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/FilteredReporter.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/FilteredReporter.scala @@ -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)) ) } diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/ForkedJava.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/ForkedJava.scala index 412819dba1..6a6fb039d2 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/ForkedJava.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/ForkedJava.scala @@ -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( @@ -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, + ) } diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala index a4fee662a2..b305a053dd 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/javac/LocalJava.scala @@ -104,7 +104,6 @@ object LocalJava { ): Int = { (javadocTool, standardDocletClass) match { case (Some(m), Some(clz)) => - import scala.collection.JavaConverters._ val task = m.getTask( out, null, @@ -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...") diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala index e6df712f16..3a895f887e 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Changes.scala @@ -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 -> _)) diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/FileValueCache.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/FileValueCache.scala index 8a18086573..aa7b805c86 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/FileValueCache.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/FileValueCache.scala @@ -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)( diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala index 72ec426a91..7a3fa13c18 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala @@ -201,7 +201,7 @@ object Incremental { earlyOutput, progress, log - ) + )(Equiv.universal) } catch { case _: xsbti.CompileCancelled => log.info("Compilation has been cancelled") @@ -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( diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Locate.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Locate.scala index be849cdf58..b3b09c3bf8 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Locate.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Locate.scala @@ -49,7 +49,7 @@ object Locate { } } def find[S](name: String, gets: Stream[String => Either[Boolean, S]]): Either[Boolean, S] = - find[S](name, gets.toIterator) + find[S](name, gets.iterator) /** * Returns a function that searches the provided class path for @@ -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) } } diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/SourceInfo.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/SourceInfo.scala index bf084b09bc..b274f4b089 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/SourceInfo.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/SourceInfo.scala @@ -38,14 +38,17 @@ object SourceInfos { ): SourceInfo = new UnderlyingSourceInfo(reported, unreported, mainClasses) - def merge(infos: Traversable[SourceInfos]): SourceInfos = + def merge(infos: Iterable[SourceInfos]): SourceInfos = infos.foldLeft(SourceInfos.empty)(_ ++ _) 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, ) } @@ -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.collection.JavaConverters._ + allInfos.asJava } } diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala index 58d14906b9..4b3b2205da 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Stamp.scala @@ -23,6 +23,7 @@ import xsbti.{ FileConverter, VirtualFile, VirtualFileRef } import xsbti.compile.analysis.{ ReadStamps, Stamp => XStamp } import scala.collection.immutable.TreeMap +import scala.collection.JavaConverters._ import scala.util.matching.Regex /** @@ -240,8 +241,7 @@ object Stamper { cache: collection.concurrent.Map[VirtualFileRef, (Long, XStamp)], converter: FileConverter, getStamp: VirtualFileRef => XStamp - ): VirtualFileRef => XStamp = { key: VirtualFileRef => - import scala.collection.JavaConverters._ + ): VirtualFileRef => XStamp = { (key: VirtualFileRef) => val p = converter.toPath(key) val ts = try IO.getModifiedTimeOrZero(p.toFile) @@ -311,7 +311,7 @@ object Stamps { ): Stamps = new MStamps(products, sources, libraries) - def merge(stamps: Traversable[Stamps]): Stamps = stamps.foldLeft(Stamps.empty)(_ ++ _) + def merge(stamps: Iterable[Stamps]): Stamps = stamps.foldLeft(Stamps.empty)(_ ++ _) } private class MStamps( @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/UsedName.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/UsedName.scala index 684e1b7140..01e9cf0b85 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/UsedName.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/UsedName.scala @@ -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 } diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala index 683b5ae9cb..2a2cc46fcc 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/consistent/ConsistentAnalysisFormat.scala @@ -273,8 +273,8 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) { ) { val file = readMapper.mapSourceFile(VirtualFileRef.of(in.string())) val mainClasses = in.readStringSeq() - val reportedProblems = in.readArray()(readProblem()) - val unreportedProblems = in.readArray()(readProblem()) + val reportedProblems = in.readArray()(readProblem()).toIndexedSeq + val unreportedProblems = in.readArray()(readProblem()).toIndexedSeq val info = SourceInfos.makeInfo(reportedProblems, unreportedProblems, mainClasses) (file, info) }) diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/TextAnalysisFormat.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/TextAnalysisFormat.scala index 4f055b5f24..22a1a9e1d2 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/TextAnalysisFormat.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/TextAnalysisFormat.scala @@ -484,9 +484,21 @@ class TextAnalysisFormat(val mappers: ReadWriteMappers) .map(fh => fh.withFile(writeMapper.mapClasspathEntry(fh.file))) writeSeq(out)(Headers.outputMode, mode :: Nil, identity[String]) writeMap(out)(Headers.outputDir, outputAsMap, sourceDirMapper.write, outputDirMapper.write) - writeSeq(out)(Headers.classpathHash, mappedClasspathHash, fileHashToString) - writeSeq(out)(Headers.compileOptions, setup.options.scalacOptions, soptionsMapper.write) - writeSeq(out)(Headers.javacOptions, setup.options.javacOptions, joptionsMapper.write) + writeSeq(out)( + Headers.classpathHash, + mappedClasspathHash.toIndexedSeq, + fileHashToString + ) + writeSeq(out)( + Headers.compileOptions, + setup.options.scalacOptions.toIndexedSeq, + soptionsMapper.write + ) + writeSeq(out)( + Headers.javacOptions, + setup.options.javacOptions.toIndexedSeq, + joptionsMapper.write + ) writeSeq(out)(Headers.compilerVersion, setup.compilerVersion :: Nil, identity[String]) writeSeq(out)(Headers.compileOrder, setup.order.name :: Nil, identity[String]) writeSeq(out)(Headers.skipApiStoring, setup.storeApis() :: Nil, (b: Boolean) => b.toString) diff --git a/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala b/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala index f73696eb67..9ce08dfedc 100644 --- a/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala +++ b/internal/zinc-persist/src/test/scala/sbt/inc/AnalysisGenerators.scala @@ -104,7 +104,7 @@ object AnalysisGenerators { private[this] def lzy[T <: AnyRef](x: T) = SafeLazyProxy.strict(x) def genNameHash(name: String): Gen[NameHash] = - for (scope <- oneOf(UseScope.values())) + for (scope <- oneOf(UseScope.values().toIndexedSeq)) yield NameHash.of(name, scope, (name, scope).hashCode()) def genClass(name: String): Gen[AnalyzedClass] = diff --git a/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala b/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala index 4d9cba150f..d282f43387 100644 --- a/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala +++ b/internal/zinc-scripted/src/test/scala/sbt/internal/inc/IncHandler.scala @@ -515,7 +515,7 @@ case class ProjectStructure( case Seq(mainClassName) => val jars = i.si.allJars.map(_.toPath) val cp = (jars ++ (unmanagedJars :+ output) ++ internalClasspath).map(_.toAbsolutePath) - val loader = ClasspathUtil.makeLoader(cp, i.si, baseDirectory) + val loader = ClasspathUtil.makeLoader(cp.toIndexedSeq, i.si, baseDirectory) val buffer = new ByteArrayOutputStream(8192) val oldOut = System.out try { diff --git a/zinc/src/main/scala/sbt/internal/inc/IncrementalCompilerImpl.scala b/zinc/src/main/scala/sbt/internal/inc/IncrementalCompilerImpl.scala index b954db27c6..bef4b8983c 100644 --- a/zinc/src/main/scala/sbt/internal/inc/IncrementalCompilerImpl.scala +++ b/zinc/src/main/scala/sbt/internal/inc/IncrementalCompilerImpl.scala @@ -58,15 +58,15 @@ class IncrementalCompilerImpl extends IncrementalCompiler { compileIncrementally( scalac, javacChosen, - sources, - classpath, + sources.toIndexedSeq, + classpath.toIndexedSeq, CompileOutput(classesDirectory), earlyOutput.toOption, earlyAnalysisStore.toOption, cache, progress().toOption, - scalacOptions, - javacOptions, + scalacOptions.toIndexedSeq, + javacOptions.toIndexedSeq, in.previousResult.analysis.toOption, in.previousResult.setup.toOption, perClasspathEntryLookup, @@ -113,15 +113,15 @@ class IncrementalCompilerImpl extends IncrementalCompiler { compileIncrementally( scalac, javacChosen, - sources, - classpath, + sources.toIndexedSeq, + classpath.toIndexedSeq, CompileOutput(classesDirectory), earlyOutput.toOption, earlyAnalysisStore.toOption, cache, progress().toOption, - scalacOptions, - javacOptions, + scalacOptions.toIndexedSeq, + javacOptions.toIndexedSeq, in.previousResult.analysis.toOption, in.previousResult.setup.toOption, perClasspathEntryLookup, @@ -295,7 +295,7 @@ class IncrementalCompilerImpl extends IncrementalCompiler { compileIncrementally( scalaCompiler, javaCompiler, - vs, + vs.toIndexedSeq, cp, output, earlyOutput.toOption, diff --git a/zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala b/zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala index 457cbb389f..b08b699d1d 100644 --- a/zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala +++ b/zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala @@ -78,7 +78,7 @@ final class MixedAnalyzingCompiler( javaSrcs, Seq(toVirtualFile(outputJar)), config.converter, - joptions, + joptions.toIndexedSeq, CompileOutput(outputDir), outputJarOpt, callback, @@ -94,7 +94,7 @@ final class MixedAnalyzingCompiler( javaSrcs, extraClasspath map toVirtualFile, config.converter, - joptions, + joptions.toIndexedSeq, output, outputJarOpt, callback, @@ -143,7 +143,8 @@ final class MixedAnalyzingCompiler( val incSrc = config.sources.filter(include) val (javaSrcs, scalaSrcs) = incSrc.partition(MixedAnalyzingCompiler.javaOnly) logInputs(log, javaSrcs.size, scalaSrcs.size, outputDirs) - val pickleJava = Incremental.isPickleJava(config.currentSetup.options.scalacOptions) + val pickleJava = + Incremental.isPickleJava(config.currentSetup.options.scalacOptions.toIndexedSeq) // Compile Scala sources. def compileScala(): Unit = @@ -240,7 +241,8 @@ final class MixedAnalyzingCompiler( private[this] def outputDirectories(output: Output): Seq[Path] = { output match { case single: SingleOutput => List(single.getOutputDirectoryAsPath) - case mult: MultipleOutput => mult.getOutputGroups map (_.getOutputDirectoryAsPath) + case mult: MultipleOutput => + mult.getOutputGroups.toIndexedSeq map (_.getOutputDirectoryAsPath) } } @@ -415,7 +417,7 @@ object MixedAnalyzingCompiler { val cArgs = new CompilerArguments(compiler.scalaInstance, compiler.classpathOptions) val searchClasspath: Seq[VirtualFile] = explicitBootClasspath( - scalacOptions, + scalacOptions.toIndexedSeq, converter ) ++ withBootclasspath( diff --git a/zinc/src/main/scala/sbt/internal/inc/javac/AnalyzingJavaCompiler.scala b/zinc/src/main/scala/sbt/internal/inc/javac/AnalyzingJavaCompiler.scala index 6d0f3630f8..2ae4c34cd5 100644 --- a/zinc/src/main/scala/sbt/internal/inc/javac/AnalyzingJavaCompiler.scala +++ b/zinc/src/main/scala/sbt/internal/inc/javac/AnalyzingJavaCompiler.scala @@ -142,7 +142,7 @@ final class AnalyzingJavaCompiler private[sbt] ( } // Memoize the known class files in the Javac output location - val memo = for { (Some(outputPath), srcs) <- chunks } yield { + val memo = for { case (Some(outputPath), srcs) <- chunks } yield { val classFinder = if (outputPath.toString.endsWith(".jar")) new JarClassFinder(outputPath) else new DirectoryClassFinder(outputPath) diff --git a/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala b/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala index d6704c547c..58107ab9ec 100644 --- a/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala +++ b/zinc/src/test/scala/sbt/inc/cached/CachedHashingSpec.scala @@ -62,13 +62,13 @@ class CachedHashingSpec extends BaseCompilerSpec { def genConfig = MixedAnalyzingCompiler.makeConfig( scalac, javac, - options.sources, + options.sources.toIndexedSeq, options.converter.toOption.get, giganticClasspath, setup.cache, setup.progress.toOption, - options.scalacOptions, - options.javacOptions, + options.scalacOptions.toIndexedSeq, + options.javacOptions.toIndexedSeq, Analysis.empty, previousResult.setup.toOption, setup.perClasspathEntryLookup, From ded724840ec3e1a2bb00d8b78333236ac26581e8 Mon Sep 17 00:00:00 2001 From: Friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:28:03 -0700 Subject: [PATCH 2/5] Add more missing .toIndexedSeq calls --- .../scala/sbt/internal/inc/ClassToAPI.scala | 6 ++--- .../src/main/scala/xsbt/api/Discovery.scala | 14 ++++++----- .../src/main/scala/xsbt/api/ShowAPI.scala | 24 +++++++++++-------- .../sbt/internal/inc/CompilerArguments.scala | 3 ++- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala b/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala index 2a91f0cf89..693a0523f2 100644 --- a/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala +++ b/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala @@ -507,11 +507,11 @@ object ClassToAPI { * We need this logic to trigger recompilation due to changes to pattern exhaustivity checking results. */ private def childrenOfSealedClass(c: Class[?]): Seq[api.Type] = - if (!c.isEnum) emptyTypeArray + if (!c.isEnum) emptyTypeArray.toIndexedSeq else { // Calling getCanonicalName() on classes from enum constants yields same string as enumClazz.getCanonicalName // Moreover old behaviour create new instance of enum - what may fail (e.g. in static block ) - Array(reference(c)) + Seq(reference(c)) } // full information not available from reflection @@ -556,7 +556,7 @@ object ClassToAPI { } def pathFromString(s: String): api.Path = - pathFromStrings(s.split("\\.")) + pathFromStrings(s.split("\\.").toIndexedSeq) def pathFromStrings(ss: Seq[String]): api.Path = api.Path.of((ss.map(api.Id.of(_)) :+ ThisRef).toArray) def packageName(c: Class[?]) = packageAndName(c)._1 diff --git a/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala b/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala index 608a1c8dad..9801e89e39 100644 --- a/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala +++ b/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala @@ -34,13 +34,13 @@ class Discovery(baseClasses: Set[String], annotations: Set[String]) { case _ => Discovered.empty } def discover(c: ClassLike): Discovered = { - val onClass = Discovery.findAnnotations(c.annotations, annotations) + val onClass = Discovery.findAnnotations(c.annotations.toIndexedSeq, annotations) val onDefs = Discovery.defAnnotations(c.structure, annotations) ++ c.savedAnnotations.filter( annotations ) val module = isModule(c) new Discovered( - bases(c.name, c.structure.parents), + bases(c.name, c.structure.parents.toIndexedSeq), onClass ++ onDefs, module && hasMainMethod(c), module @@ -66,7 +66,7 @@ object Discovery { simpleName(a.base).filter(pred) }.toSet def defAnnotations(s: Structure, pred: String => Boolean): Set[String] = - defAnnotations(s.declared, pred) ++ defAnnotations(s.inherited, pred) + defAnnotations(s.declared.toIndexedSeq, pred) ++ defAnnotations(s.inherited, pred) def defAnnotations(defs: Seq[Definition], pred: String => Boolean): Set[String] = findAnnotations( defs.flatMap { @@ -82,19 +82,21 @@ object Discovery { def isModule(c: ClassLike) = c.definitionType == DefinitionType.Module def hasMainMethod(c: ClassLike): Boolean = - hasMainMethod(c.structure.declared) || hasMainMethod(c.structure.inherited) + hasMainMethod(c.structure.declared.toIndexedSeq) || hasMainMethod( + c.structure.inherited.toIndexedSeq + ) def hasMainMethod(defs: Seq[Definition]): Boolean = defs.exists(isMainMethod) def isMainMethod(d: Definition): Boolean = d match { case d: Def => d.name == "main" && isPublic(d) && isConcrete(d) && isUnit(d.returnType) && isStringArray( - d.valueParameters + d.valueParameters.toIndexedSeq ) case _ => false } def isStringArray(vp: IndexedSeq[ParameterList]): Boolean = - vp.length == 1 && isStringArray(vp(0).parameters) + vp.length == 1 && isStringArray(vp(0).parameters.toIndexedSeq) def isStringArray(params: Seq[MethodParameter]): Boolean = params.length == 1 && isStringArray(params(0)) def isStringArray(p: MethodParameter): Boolean = diff --git a/internal/zinc-apiinfo/src/main/scala/xsbt/api/ShowAPI.scala b/internal/zinc-apiinfo/src/main/scala/xsbt/api/ShowAPI.scala index 3c706b8b61..14ae4f456f 100644 --- a/internal/zinc-apiinfo/src/main/scala/xsbt/api/ShowAPI.scala +++ b/internal/zinc-apiinfo/src/main/scala/xsbt/api/ShowAPI.scala @@ -41,12 +41,14 @@ object ShowAPI { case v: Val => showMonoDef(v, "val") + ": " + showType(v.tpe) case v: Var => showMonoDef(v, "var") + ": " + showType(v.tpe) case d: Def => - showPolyDef(d, "def") + showValueParams(d.valueParameters) + ": " + showType(d.returnType) + showPolyDef(d, "def") + showValueParams(d.valueParameters.toIndexedSeq) + ": " + showType( + d.returnType + ) case ta: TypeAlias => showPolyDef(ta, "type") + " = " + showType(ta.tpe) case td: TypeDeclaration => showPolyDef(td, "type") + showBounds(td.lowerBound, td.upperBound) case cl: ClassLike => showMonoDef(d, showDefinitionType(cl.definitionType)) + - showTypeParameters(cl.typeParameters) + " extends " + showTemplate(cl) + showTypeParameters(cl.typeParameters.toIndexedSeq) + " extends " + showTemplate(cl) case cl: ClassLikeDef => showPolyDef(cl, showDefinitionType(cl.definitionType)) } @@ -59,9 +61,11 @@ object ShowAPI { cl.structure.parents.map(showNestedType).mkString("", " with ", " {") + showSelf + lines( - truncateDecls(cl.structure.inherited).map(d => "^inherited^ " + showNestedDefinition(d)) + truncateDecls(cl.structure.inherited).toIndexedSeq.map(d => + "^inherited^ " + showNestedDefinition(d) + ) ) + - lines(truncateDecls(cl.structure.declared).map(showNestedDefinition)) + + lines(truncateDecls(cl.structure.declared).toIndexedSeq.map(showNestedDefinition)) + "}" } @@ -73,7 +77,7 @@ object ShowAPI { case p: Parameterized => showType(p.baseType) + p.typeArguments.map(showType).mkString("[", ", ", "]") case c: Constant => showType(c.baseType) + "(" + c.value + ")" - case a: Annotated => showAnnotations(a.annotations) + " " + showType(a.baseType) + case a: Annotated => showAnnotations(a.annotations.toIndexedSeq) + " " + showType(a.baseType) case s: Structure => s.parents.map(showType).mkString(" with ") + ( if (nesting <= 0) "{ }" @@ -90,7 +94,7 @@ object ShowAPI { case p: Polymorphic => showType(p.baseType) + ( if (nesting <= 0) " [ ]" - else showNestedTypeParameters(p.parameters) + else showNestedTypeParameters(p.parameters.toIndexedSeq) ) } @@ -103,22 +107,22 @@ object ShowAPI { private def space(s: String) = if (s.isEmpty) s else s + " " private def showMonoDef(d: Definition, label: String)(implicit nesting: Int): String = - space(showAnnotations(d.annotations)) + space(showAccess(d.access)) + space( + space(showAnnotations(d.annotations.toIndexedSeq)) + space(showAccess(d.access)) + space( showModifiers(d.modifiers) ) + space(label) + d.name private def showPolyDef(d: ParameterizedDefinition, label: String)( implicit nesting: Int ): String = - showMonoDef(d, label) + showTypeParameters(d.typeParameters) + showMonoDef(d, label) + showTypeParameters(d.typeParameters.toIndexedSeq) private def showTypeParameters(tps: Seq[TypeParameter])(implicit nesting: Int): String = if (tps.isEmpty) "" else tps.map(showTypeParameter).mkString("[", ", ", "]") private def showTypeParameter(tp: TypeParameter)(implicit nesting: Int): String = - showAnnotations(tp.annotations) + " " + showVariance(tp.variance) + tp.id + showTypeParameters( - tp.typeParameters + showAnnotations(tp.annotations.toIndexedSeq) + " " + showVariance(tp.variance) + tp.id + showTypeParameters( + tp.typeParameters.toIndexedSeq ) + " " + showBounds(tp.lowerBound, tp.upperBound) private def showAnnotations(as: Seq[Annotation])(implicit nesting: Int) = diff --git a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala index f490e91508..c6834ada4f 100644 --- a/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala +++ b/internal/zinc-compile-core/src/main/scala/sbt/internal/inc/CompilerArguments.scala @@ -88,7 +88,8 @@ final class CompilerArguments( */ def finishClasspath(classpath: Seq[Path]): Seq[Path] = { val filteredClasspath = filterLibrary(classpath) - val extraCompiler = include(cpOptions.compiler, scalaInstance.compilerJars.map(_.toPath): _*) + val extraCompiler = + include(cpOptions.compiler, scalaInstance.compilerJars.toIndexedSeq.map(_.toPath): _*) val otherJars = scalaInstance.otherJars.toList.map(_.toPath) val extraClasspath = include(cpOptions.extra, otherJars: _*) filteredClasspath ++ extraCompiler ++ extraClasspath From 3dc678326a2603c9f03188ffd36e347ffe18ba01 Mon Sep 17 00:00:00 2001 From: Friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:02:27 -0700 Subject: [PATCH 3/5] Add even more missing .toIndexedSeq calls --- .../internal/inc/CompilingSpecification.scala | 8 ++-- .../scala/sbt/internal/inc/ClassToAPI.scala | 29 ++++++++++---- .../src/main/scala/xsbt/api/Discovery.scala | 2 +- .../src/main/scala/xsbt/api/HashAPI.scala | 4 +- .../src/main/scala/xsbt/api/SameAPI.scala | 38 +++++++++++-------- .../sbt/internal/inc/classfile/Parser.scala | 2 +- .../sbt/internal/inc/ScalaInstance.scala | 2 +- .../inc/classpath/ClasspathUtilities.scala | 2 +- 8 files changed, 54 insertions(+), 33 deletions(-) diff --git a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala index 519499e286..2b48f17816 100644 --- a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala +++ b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala @@ -281,8 +281,8 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit { val cp = (si.allJars).map(_.toPath) ++ Array(targetDir) val classpath = cp.map(converter.toVirtualFile) sc.doc( - sources = sources.toArray[VirtualFile], - classpath = classpath, + sources = sources.toIndexedSeq, + classpath = classpath.toIndexedSeq, converter = converter, outputDirectory = targetDir, options = Nil, @@ -305,7 +305,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit { val cp = (si.allJars).map(_.toPath) ++ Array(targetDir) val classpath = cp.map(converter.toVirtualFile) sc.console( - classpath = classpath, + classpath = classpath.toIndexedSeq, converter = converter, options = Nil, initialCommands = initial, @@ -327,7 +327,7 @@ trait CompilingSpecification extends AbstractBridgeProviderTestkit { val cp = (si.allJars).map(_.toPath) ++ Array(targetDir) val classpath = cp.map(converter.toVirtualFile) sc.interactiveConsole( - classpath = classpath, + classpath = classpath.toIndexedSeq, converter = converter, options = args.toSeq, initialCommands = "", diff --git a/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala b/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala index 693a0523f2..d3506f73d7 100644 --- a/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala +++ b/internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala @@ -191,14 +191,29 @@ object ClassToAPI { cmap: ClassMap ): (api.Structure, api.Structure) = { lazy val cf = classFileForClass(c) - val methods = mergeMap(c, c.getDeclaredMethods, c.getMethods, methodToDef(enclPkg)) - val fields = mergeMap(c, c.getDeclaredFields, c.getFields, fieldToDef(c, cf, enclPkg)) + val methods = mergeMap( + c, + c.getDeclaredMethods.toIndexedSeq, + c.getMethods.toIndexedSeq, + methodToDef(enclPkg) + ) + val fields = mergeMap( + c, + c.getDeclaredFields.toIndexedSeq, + c.getFields.toIndexedSeq, + fieldToDef(c, cf, enclPkg) + ) val constructors = - mergeMap(c, c.getDeclaredConstructors, c.getConstructors, constructorToDef(enclPkg)) + mergeMap( + c, + c.getDeclaredConstructors.toIndexedSeq, + c.getConstructors.toIndexedSeq, + constructorToDef(enclPkg) + ) val classes = merge[Class[?]]( c, - c.getDeclaredClasses, - c.getClasses, + c.getDeclaredClasses.toIndexedSeq, + c.getClasses.toIndexedSeq, toDefinitions(cmap), (_: Seq[Class[?]]).partition(isStatic), _.getEnclosingClass != c @@ -240,7 +255,7 @@ object ClassToAPI { private def allSuperTypes(t: Type): Seq[Type] = { @tailrec def accumulate(t: Type, accum: Seq[Type] = Seq.empty): Seq[Type] = t match { case c: Class[?] => - val (parent, interfaces) = (c.getGenericSuperclass, c.getGenericInterfaces) + val (parent, interfaces) = (c.getGenericSuperclass, c.getGenericInterfaces.toIndexedSeq) accumulate(parent, (accum :+ parent) ++ flattenAll(interfaces)) case p: ParameterizedType => accumulate(p.getRawType, accum) @@ -263,7 +278,7 @@ object ClassToAPI { def types(ts: Seq[Type]): Array[api.Type] = ts.filter(_ ne null).map(reference).toArray def upperBounds(ts: Array[Type]): api.Type = - api.Structure.of(lzy(types(ts)), lzyEmptyDefArray, lzyEmptyDefArray) + api.Structure.of(lzy(types(ts.toIndexedSeq)), lzyEmptyDefArray, lzyEmptyDefArray) @deprecated("No longer used", "0.13.0") def parents(c: Class[?]): Seq[api.Type] = types(allSuperTypes(c)) diff --git a/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala b/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala index 9801e89e39..e5e0313d26 100644 --- a/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala +++ b/internal/zinc-apiinfo/src/main/scala/xsbt/api/Discovery.scala @@ -66,7 +66,7 @@ object Discovery { simpleName(a.base).filter(pred) }.toSet def defAnnotations(s: Structure, pred: String => Boolean): Set[String] = - defAnnotations(s.declared.toIndexedSeq, pred) ++ defAnnotations(s.inherited, pred) + defAnnotations(s.declared.toIndexedSeq, pred) ++ defAnnotations(s.inherited.toIndexedSeq, pred) def defAnnotations(defs: Seq[Definition], pred: String => Boolean): Set[String] = findAnnotations( defs.flatMap { diff --git a/internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala b/internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala index 8752540595..90349cac35 100644 --- a/internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala +++ b/internal/zinc-apiinfo/src/main/scala/xsbt/api/HashAPI.scala @@ -432,8 +432,8 @@ final class HashAPI private ( extend(StructureHash) hashTypes(structure.parents, includeDefinitions) if (includeDefinitions) { - hashDefinitions(structure.declared, false, isTrait) - hashDefinitions(structure.inherited, false, isTrait) + hashDefinitions(structure.declared.toIndexedSeq, false, isTrait) + hashDefinitions(structure.inherited.toIndexedSeq, false, isTrait) } } def hashParameters(parameters: Array[TypeParameter], base: Type): Unit = { diff --git a/internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala b/internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala index bc926caa5f..8049d611f6 100644 --- a/internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala +++ b/internal/zinc-apiinfo/src/main/scala/xsbt/api/SameAPI.scala @@ -139,7 +139,10 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { // a.name == b.name && debug(sameAccess(a.access, b.access), "Access differed") && debug(sameModifiers(a.modifiers, b.modifiers), "Modifiers differed") && - debug(sameAnnotations(a.annotations, b.annotations), "Annotations differed") && + debug( + sameAnnotations(a.annotations.toIndexedSeq, b.annotations.toIndexedSeq), + "Annotations differed" + ) && debug(sameDefinitionSpecificAPI(a, b), "Definition-specific differed") } @@ -184,7 +187,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { def sameAnnotation(a: Annotation, b: Annotation): Boolean = debug(sameType(a.base, b.base), "Annotation base type differed") && debug( - sameAnnotationArguments(a.arguments, b.arguments), + sameAnnotationArguments(a.arguments.toIndexedSeq, b.arguments.toIndexedSeq), "Annotation arguments differed (" + a + ") and (" + b + ")" ) def sameAnnotationArguments(a: Seq[AnnotationArgument], b: Seq[AnnotationArgument]): Boolean = @@ -203,7 +206,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { def sameParameterizedDefinition(a: ParameterizedDefinition, b: ParameterizedDefinition): Boolean = debug( - sameTypeParameters(a.typeParameters, b.typeParameters), + sameTypeParameters(a.typeParameters.toIndexedSeq, b.typeParameters.toIndexedSeq), "Different type parameters for " + a.name ) && sameParameterizedSpecificAPI(a, b) @@ -222,7 +225,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { def sameDefSpecificAPI(a: Def, b: Def): Boolean = debug( - sameValueParameters(a.valueParameters, b.valueParameters), + sameValueParameters(a.valueParameters.toIndexedSeq, b.valueParameters.toIndexedSeq), "Different def value parameters for " + a.name ) && debug(sameType(a.returnType, b.returnType), "Different def return type for " + a.name) @@ -253,7 +256,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { debug(sameTopLevel(a, b), "Top level flag differs") && sameDefinitionType(a.definitionType, b.definitionType) && sameType(a.selfType, b.selfType) && - sameSeq(a.childrenOfSealedClass, b.childrenOfSealedClass)(sameType) && + sameSeq(a.childrenOfSealedClass.toIndexedSeq, b.childrenOfSealedClass.toIndexedSeq)(sameType) && sameStructure(a.structure, b.structure) } @@ -265,7 +268,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { def sameParameterList(a: ParameterList, b: ParameterList): Boolean = (a.isImplicit == b.isImplicit) && - sameParameters(a.parameters, b.parameters) + sameParameters(a.parameters.toIndexedSeq, b.parameters.toIndexedSeq) def sameParameters(a: Seq[MethodParameter], b: Seq[MethodParameter]): Boolean = sameSeq(a, b)(sameMethodParameter) def sameMethodParameter(a: MethodParameter, b: MethodParameter): Boolean = @@ -283,8 +286,11 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { def sameTypeParameters(a: Seq[TypeParameter], b: Seq[TypeParameter]): Boolean = debug(sameSeq(a, b)(sameTypeParameter), "Different type parameters") def sameTypeParameter(a: TypeParameter, b: TypeParameter): Boolean = { - sameTypeParameters(a.typeParameters, b.typeParameters) && - debug(sameAnnotations(a.annotations, b.annotations), "Different type parameter annotations") && + sameTypeParameters(a.typeParameters.toIndexedSeq, b.typeParameters.toIndexedSeq) && + debug( + sameAnnotations(a.annotations.toIndexedSeq, b.annotations.toIndexedSeq), + "Different type parameter annotations" + ) && debug(sameVariance(a.variance, b.variance), "Different variance") && debug(sameType(a.lowerBound, b.lowerBound), "Different lower bound") && debug(sameType(a.upperBound, b.upperBound), "Different upper bound") && @@ -326,14 +332,14 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { sameType(ca.baseType, cb.baseType) && ca.value == cb.value def sameExistentialType(a: Existential, b: Existential): Boolean = - sameTypeParameters(a.clause, b.clause) && + sameTypeParameters(a.clause.toIndexedSeq, b.clause.toIndexedSeq) && sameType(a.baseType, b.baseType) def samePolymorphicType(a: Polymorphic, b: Polymorphic): Boolean = - sameTypeParameters(a.parameters, b.parameters) && + sameTypeParameters(a.parameters.toIndexedSeq, b.parameters.toIndexedSeq) && sameType(a.baseType, b.baseType) def sameAnnotatedType(a: Annotated, b: Annotated): Boolean = sameType(a.baseType, b.baseType) && - sameAnnotations(a.annotations, b.annotations) + sameAnnotations(a.annotations.toIndexedSeq, b.annotations.toIndexedSeq) def sameStructure(a: Structure, b: Structure): Boolean = samePending(a, b)(sameStructureDirect) @@ -341,9 +347,9 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { if (pending add ((a, b))) f(a, b) else true def sameStructureDirect(a: Structure, b: Structure): Boolean = { - sameSeq(a.parents, b.parents)(sameType) && - sameMembers(a.declared, b.declared) && - sameMembers(a.inherited, b.inherited) + sameSeq(a.parents.toIndexedSeq, b.parents.toIndexedSeq)(sameType) && + sameMembers(a.declared.toIndexedSeq, b.declared.toIndexedSeq) && + sameMembers(a.inherited.toIndexedSeq, b.inherited.toIndexedSeq) } def sameMembers(a: Seq[Definition], b: Seq[Definition]): Boolean = @@ -358,7 +364,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { def sameParameterized(a: Parameterized, b: Parameterized): Boolean = sameType(a.baseType, b.baseType) && - sameSeq(a.typeArguments, b.typeArguments)(sameType) + sameSeq(a.typeArguments.toIndexedSeq, b.typeArguments.toIndexedSeq)(sameType) def sameParameterRef(a: ParameterRef, b: ParameterRef): Boolean = sameTags(a.id, b.id) def sameSingleton(a: Singleton, b: Singleton): Boolean = samePath(a.path, b.path) @@ -367,7 +373,7 @@ class SameAPI(includePrivate: Boolean, includeParamNames: Boolean) { (a.id == b.id) def samePath(a: Path, b: Path): Boolean = - samePathComponents(a.components, b.components) + samePathComponents(a.components.toIndexedSeq, b.components.toIndexedSeq) def samePathComponents(a: Seq[PathComponent], b: Seq[PathComponent]): Boolean = sameSeq(a, b)(samePathComponent) def samePathComponent(a: PathComponent, b: PathComponent): Boolean = diff --git a/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala b/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala index 01744c1092..edbc7c3da1 100644 --- a/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala +++ b/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala @@ -106,7 +106,7 @@ private[sbt] object Parser { in.readUnsignedShort(), toString(in.readUnsignedShort()), toString(in.readUnsignedShort()), - array(in.readUnsignedShort())(parseAttribute()) + array(in.readUnsignedShort())(parseAttribute()).toIndexedSeq ) private def parseAttribute() = { val nameIndex = in.readUnsignedShort() diff --git a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/ScalaInstance.scala b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/ScalaInstance.scala index 41ee277c2f..b282301521 100644 --- a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/ScalaInstance.scala +++ b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/ScalaInstance.scala @@ -266,7 +266,7 @@ object ScalaInstance { /** Return all the required Scala jars from a path `scalaHome`. */ def allJars(scalaHome: File): Seq[File] = - IO.listFiles(scalaLib(scalaHome)).filter(f => !blacklist(f.getName)) + IO.listFiles(scalaLib(scalaHome)).toIndexedSeq.filter(f => !blacklist(f.getName)) private[this] def scalaLib(scalaHome: File): File = new File(scalaHome, "lib") diff --git a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClasspathUtilities.scala b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClasspathUtilities.scala index 944e15f7f7..aea685817d 100644 --- a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClasspathUtilities.scala +++ b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClasspathUtilities.scala @@ -81,7 +81,7 @@ object ClasspathUtil { classpath: Seq[Path], instance: ScalaInstance ): Map[String, String] = { - createClasspathResources(classpath, instance.libraryJars.map(_.toPath)) + createClasspathResources(classpath, instance.libraryJars.toIndexedSeq.map(_.toPath)) } def createClasspathResources(appPaths: Seq[Path], bootPaths: Seq[Path]): Map[String, String] = { From 1f63557191a9bdc81a39cf3ac8c90117cff574fc Mon Sep 17 00:00:00 2001 From: Friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:44:23 -0700 Subject: [PATCH 4/5] Remove an unused import --- .../src/test/scala/sbt/internal/inc/CompilingSpecification.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala index 2b48f17816..e926b52654 100644 --- a/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala +++ b/internal/compiler-bridge-test/src/test/scala/sbt/internal/inc/CompilingSpecification.scala @@ -9,7 +9,6 @@ import java.util.Optional import sbt.internal.inc.classpath.ClassLoaderCache import sbt.io.IO -import sbt.io.syntax._ import xsbti.compile._ import sbt.util.Logger import xsbti.TestCallback.ExtractedClassDependencies From e74d3e45a5af469d6b9868f86bb41fcaff532405 Mon Sep 17 00:00:00 2001 From: Friendseeker <66892505+Friendseeker@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:51:53 -0700 Subject: [PATCH 5/5] Fix some more deprecation warnings --- .../src/main/scala/sbt/internal/inc/classfile/Parser.scala | 6 +++--- .../scala/sbt/internal/inc/classpath/ClassLoaders.scala | 4 ++-- .../src/main/scala/sbt/internal/inc/Compilations.scala | 2 +- .../main/scala/sbt/internal/inc/text/FormatCommons.scala | 2 +- .../scala/sbt/internal/inc/text/RelationsTextFormat.scala | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala b/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala index edbc7c3da1..28f560a00f 100644 --- a/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala +++ b/internal/zinc-classfile/src/main/scala/sbt/internal/inc/classfile/Parser.scala @@ -39,13 +39,13 @@ import Constants._ private[sbt] object Parser { def apply(file: Path, log: Logger): ClassFile = - Using.bufferedInputStream(Files.newInputStream(file))(parse(file.toString, log)).right.get + Using.bufferedInputStream(Files.newInputStream(file))(parse(file.toString, log)).toOption.get def apply(file: File, log: Logger): ClassFile = - Using.fileInputStream(file)(parse(file.toString, log)).right.get + Using.fileInputStream(file)(parse(file.toString, log)).toOption.get def apply(url: URL, log: Logger): ClassFile = - usingUrlInputStreamWithoutCaching(url)(parse(url.toString, log)).right.get + usingUrlInputStreamWithoutCaching(url)(parse(url.toString, log)).toOption.get // JarURLConnection with caching enabled will never close the jar private val usingUrlInputStreamWithoutCaching = Using.resource((u: URL) => diff --git a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala index 3074c2d236..fde68b471f 100644 --- a/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala +++ b/internal/zinc-classpath/src/main/scala/sbt/internal/inc/classpath/ClassLoaders.scala @@ -191,8 +191,8 @@ trait NativeCopyLoader extends ClassLoader { private[this] def findLibrary0(name: String): String = { val mappedName = System.mapLibraryName(name) - val explicit = explicitLibraries.toIterator.filter(_.getFileName.toString == mappedName) - val search = searchPaths.toIterator flatMap relativeLibrary(mappedName) + val explicit = explicitLibraries.iterator.filter(_.getFileName.toString == mappedName) + val search = searchPaths.iterator flatMap relativeLibrary(mappedName) val combined = explicit ++ search if (combined.hasNext) copy(combined.next()) else null } diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/Compilations.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/Compilations.scala index b8021a66bb..f992ee7fb2 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/Compilations.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/Compilations.scala @@ -30,7 +30,7 @@ trait Compilations extends ReadCompilations { object Compilations { val empty: Compilations = new MCompilations(Seq.empty) def of(s: Seq[Compilation]): Compilations = new MCompilations(s) - def merge(s: Traversable[Compilations]): Compilations = + def merge(s: Iterable[Compilations]): Compilations = of((s flatMap { _.allCompilations }).toSeq.distinct) } diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/FormatCommons.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/FormatCommons.scala index eef736e0a3..20d28cd06b 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/FormatCommons.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/FormatCommons.scala @@ -155,7 +155,7 @@ trait FormatCommons { protected def readMappedPairs[K, V]( in: BufferedReader - )(expectedHeader: String, s2k: String => K, s2v: (K, String) => V): Traversable[(K, V)] = { + )(expectedHeader: String, s2k: String => K, s2v: (K, String) => V): Iterable[(K, V)] = { def toPair(s: String): (K, V) = { if (s == null) throw new EOFException val p = s.indexOf(" -> ") diff --git a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/RelationsTextFormat.scala b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/RelationsTextFormat.scala index eae0ced882..495b310085 100644 --- a/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/RelationsTextFormat.scala +++ b/internal/zinc-persist/src/main/scala/sbt/internal/inc/text/RelationsTextFormat.scala @@ -82,7 +82,7 @@ trait RelationsTextFormat extends FormatCommons { def read(in: BufferedReader): Relations = { def readRelation[A, B](relDesc: Descriptor[A, B]): Map[A, Set[B]] = { import relDesc._ - val items = readPairs(in)(header, keyMapper.read, valueMapper.read).toIterator + val items = readPairs(in)(header, keyMapper.read, valueMapper.read).iterator // Reconstruct the multi-map efficiently, using the writing strategy above val builder = Map.newBuilder[A, Set[B]] var currentKey = null.asInstanceOf[A]