From 56941dac043ddb96266add491b2a0982700da4e3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 27 Oct 2024 23:55:30 -0400 Subject: [PATCH 1/2] refactor: Update Scala 3 syntax --- build.sbt | 1 + .../main/scala/sbt/internal/DslEntry.scala | 16 +- .../src/main/scala/sbt/internal/Eval.scala | 2 +- .../sbt/internal/EvaluateConfigurations.scala | 40 +-- .../scala/sbt/internal/LoadedSbtFile.scala | 6 +- .../sbt/internal/parser/SbtRefactorings.scala | 2 +- client/src/main/java/sbt/client/Client.java | 2 +- .../sbt/internal/util/appmacro/Cont.scala | 4 +- .../sbt/internal/util/appmacro/Convert.scala | 2 +- .../sbt/plugins/DependencyTreePlugin.scala | 2 +- .../scala/sbt/internal/util/LineReader.scala | 8 +- .../internal/util/complete/Completions.scala | 7 +- .../util/complete/ExampleSource.scala | 4 +- .../util/complete/JLineCompletion.scala | 6 +- .../sbt/internal/util/complete/Parser.scala | 100 +++---- .../sbt/internal/util/complete/Parsers.scala | 19 +- .../internal/util/complete/ProcessError.scala | 2 +- .../src/test/scala/ParserTest.scala | 8 +- .../scala/sbt/complete/FileExamplesTest.scala | 16 +- .../sbt/internal/util/BufferedLogger.scala | 2 +- .../sbt/internal/util/ConsoleAppender.scala | 2 +- .../scala/sbt/internal/util/Terminal.scala | 6 +- .../internal/util/codec/ProblemFormats.scala | 2 +- .../src/main/scala/sbt/util/LogExchange.scala | 2 +- .../scala/sbt/internal/util/logic/Logic.scala | 4 +- .../src/test/scala/RelationTest.scala | 2 +- .../sbt/internal/scripted/FileCommands.scala | 22 +- .../internal/scripted/FilteredLoader.scala | 2 +- .../sbt/internal/scripted/ScriptedTests.scala | 4 +- .../internal/scripted/TestScriptParser.scala | 2 +- .../librarymanagement/VersionRange.scala | 12 +- .../formats/GlobalLockFormat.scala | 4 +- .../formats/LoggerFormat.scala | 2 +- .../ConfigurationExtra.scala | 18 +- .../ConfigurationFormats.scala | 2 +- .../sbt/librarymanagement/CrossVersion.scala | 12 +- .../DependencyBuilders.scala | 2 +- .../librarymanagement/DependencyFilter.scala | 2 +- .../DependencyResolution.scala | 2 +- .../sbt/librarymanagement/EvictionError.scala | 2 +- .../sbt/librarymanagement/ResolverExtra.scala | 4 +- .../librarymanagement/UnresolvedWarning.scala | 4 +- .../librarymanagement/UpdateReportExtra.scala | 2 +- lm-core/src/test/scala/UpdateReportSpec.scala | 6 +- .../librarymanagement/VersionNumberSpec.scala | 2 +- .../lmcoursier/internal/ResolutionRun.scala | 2 +- .../scala/lmcoursier/internal/Resolvers.scala | 2 +- .../scala/lmcoursier/internal/UpdateRun.scala | 2 +- .../librarymanagement/ConvertResolver.scala | 8 +- .../librarymanagement/CustomPomParser.scala | 9 +- .../librarymanagement/FakeResolver.scala | 8 +- .../sbt/internal/librarymanagement/Ivy.scala | 13 +- .../librarymanagement/IvyActions.scala | 2 +- .../librarymanagement/IvyRetrieve.scala | 4 +- .../librarymanagement/IvyScalaUtil.scala | 2 +- .../internal/librarymanagement/MakePom.scala | 4 +- .../CachedResolutionResolveEngine.scala | 14 +- .../ivy/formats/UpdateOptionsFormat.scala | 43 ++- .../librarymanagement/EvictionErrorSpec.scala | 40 +-- .../EvictionWarningSpec.scala | 48 ++-- .../InconsistentDuplicateSpec.scala | 24 +- .../PlatformResolutionSpec.scala | 30 ++- .../librarymanagement/ResolutionSpec.scala | 4 +- .../src/main/scala/sbt/ForkTests.scala | 12 +- main-actions/src/main/scala/sbt/Pkg.scala | 12 +- .../src/main/scala/sbt/RawCompileLike.scala | 4 +- main-actions/src/main/scala/sbt/Sync.scala | 4 +- main-actions/src/main/scala/sbt/Tests.scala | 12 +- .../src/test/scala/sbt/CacheIvyTest.scala | 4 +- .../src/main/scala/sbt/BasicCommands.scala | 43 +-- main-command/src/main/scala/sbt/Command.scala | 22 +- .../src/main/scala/sbt/CommandUtil.scala | 4 +- main-command/src/main/scala/sbt/State.scala | 30 ++- .../scala/sbt/internal/LegacyWatched.scala | 6 +- .../sbt/internal/client/NetworkClient.scala | 2 +- .../scala/sbt/internal/server/Server.scala | 2 +- .../main/scala/sbt/internal/ui/UITask.scala | 2 +- main-settings/src/main/scala/sbt/Def.scala | 48 ++-- .../src/main/scala/sbt/InputTask.scala | 4 +- .../src/main/scala/sbt/Plugins.scala | 14 +- .../src/main/scala/sbt/Previous.scala | 11 +- .../src/main/scala/sbt/Project.scala | 40 +-- .../src/main/scala/sbt/Reference.scala | 8 +- main-settings/src/main/scala/sbt/Scope.scala | 14 +- .../src/main/scala/sbt/SlashSyntax.scala | 4 +- .../src/main/scala/sbt/Structure.scala | 46 ++-- .../src/main/scala/sbt/std/Instances.scala | 4 +- .../src/main/scala/sbt/std/KeyMacro.scala | 6 +- .../src/test/scala/sbt/AppendSpec.scala | 2 +- .../src/test/scala/sbt/SlashSyntaxTest.scala | 2 +- .../src/test/scala/sbt/std/TaskPosSpec.scala | 2 +- .../src/test/scala/sbt/std/UsageTest.scala | 2 +- .../main/scala/sbt/BackgroundJobService.scala | 8 +- main/src/main/scala/sbt/BuildPaths.scala | 2 +- main/src/main/scala/sbt/Cross.scala | 14 +- main/src/main/scala/sbt/Defaults.scala | 252 +++++++++--------- main/src/main/scala/sbt/EvaluateTask.scala | 18 +- .../src/main/scala/sbt/ExecuteProgress2.scala | 20 +- main/src/main/scala/sbt/Extracted.scala | 20 +- main/src/main/scala/sbt/Keys.scala | 12 +- main/src/main/scala/sbt/Main.scala | 62 +++-- main/src/main/scala/sbt/MainLoop.scala | 2 +- main/src/main/scala/sbt/Opts.scala | 8 +- main/src/main/scala/sbt/PluginCross.scala | 7 +- main/src/main/scala/sbt/ProjectExtra.scala | 96 +++---- main/src/main/scala/sbt/ProjectMatrix.scala | 60 ++--- main/src/main/scala/sbt/RemoteCache.scala | 27 +- main/src/main/scala/sbt/Resolvers.scala | 2 +- main/src/main/scala/sbt/ScopeFilter.scala | 12 +- main/src/main/scala/sbt/ScriptedPlugin.scala | 8 +- main/src/main/scala/sbt/SessionVar.scala | 10 +- .../main/scala/sbt/TemplateCommandUtil.scala | 16 +- main/src/main/scala/sbt/UpperStateOps.scala | 8 +- .../sbt/coursierint/CoursierInputsTasks.scala | 4 +- .../CoursierRepositoriesTasks.scala | 2 +- .../scala/sbt/coursierint/LMCoursier.scala | 4 +- .../sbt/internal/AbstractTaskProgress.scala | 30 +-- main/src/main/scala/sbt/internal/Act.scala | 98 +++---- .../main/scala/sbt/internal/AddSettings.scala | 6 +- .../main/scala/sbt/internal/Aggregation.scala | 32 +-- .../main/scala/sbt/internal/BuildDef.scala | 8 +- .../scala/sbt/internal/BuildStructure.scala | 28 +- .../scala/sbt/internal/ClassLoaders.scala | 2 +- .../scala/sbt/internal/ClasspathImpl.scala | 2 +- .../scala/sbt/internal/ConsoleProject.scala | 2 +- .../main/scala/sbt/internal/Continuous.scala | 16 +- .../main/scala/sbt/internal/CrossJava.scala | 18 +- .../DefaultBackgroundJobService.scala | 22 +- .../sbt/internal/DeprecatedContinuous.scala | 2 +- .../scala/sbt/internal/FileChangesMacro.scala | 2 +- .../scala/sbt/internal/GlobalPlugin.scala | 14 +- .../sbt/internal/GroupedAutoPlugins.scala | 4 +- .../scala/sbt/internal/IncrementalTest.scala | 8 +- .../src/main/scala/sbt/internal/Inspect.scala | 9 +- .../main/scala/sbt/internal/IvyConsole.scala | 12 +- .../scala/sbt/internal/JarClassPath.scala | 2 +- .../main/scala/sbt/internal/KeyIndex.scala | 72 ++--- .../sbt/internal/LibraryManagement.scala | 4 +- .../main/scala/sbt/internal/LintUnused.scala | 16 +- main/src/main/scala/sbt/internal/Load.scala | 105 ++++---- .../main/scala/sbt/internal/LogManager.scala | 42 +-- main/src/main/scala/sbt/internal/Output.scala | 16 +- .../scala/sbt/internal/PluginDiscovery.scala | 4 +- .../scala/sbt/internal/PluginManagement.scala | 2 +- .../scala/sbt/internal/PluginsDebug.scala | 14 +- .../scala/sbt/internal/ProjectQuery.scala | 2 +- .../src/main/scala/sbt/internal/Resolve.scala | 16 +- .../scala/sbt/internal/SessionSettings.scala | 34 +-- .../sbt/internal/SettingCompletions.scala | 76 +++--- .../scala/sbt/internal/SettingGraph.scala | 12 +- .../main/scala/sbt/internal/TaskName.scala | 8 +- .../scala/sbt/internal/TaskProgress.scala | 14 +- .../WatchTransitiveDependencies.scala | 20 +- .../internal/librarymanagement/IvyXml.scala | 2 +- .../internal/server/BuildServerProtocol.scala | 6 +- .../sbt/internal/server/NetworkChannel.scala | 6 +- .../sbt/internal/server/SettingQuery.scala | 16 +- main/src/main/scala/sbt/nio/FileStamp.scala | 4 +- main/src/main/scala/sbt/nio/Settings.scala | 44 +-- main/src/main/scala/sbt/nio/Watch.scala | 4 +- .../main/scala/sbt/plugins/CorePlugin.scala | 4 +- .../sbt/plugins/DependencyTreeSettings.scala | 17 +- .../sbt/plugins/Giter8TemplatePlugin.scala | 4 +- .../main/scala/sbt/plugins/IvyPlugin.scala | 4 +- .../sbt/plugins/JUnitXmlReportPlugin.scala | 4 +- .../main/scala/sbt/plugins/JvmPlugin.scala | 6 +- .../plugins/MiniDependencyTreePlugin.scala | 4 +- .../main/scala/sbt/plugins/SbtPlugin.scala | 2 +- .../scala/sbt/plugins/SemanticdbPlugin.scala | 10 +- main/src/test/scala/Delegates.scala | 4 +- main/src/test/scala/ParseKeySpec.scala | 12 +- main/src/test/scala/PluginCommandTest.scala | 6 +- main/src/test/scala/ProjectMacro.scala | 2 +- .../scala/sbt/internal/CrossJavaTest.scala | 2 +- .../test/scala/sbt/internal/TestBuild.scala | 26 +- .../JsonRpcNotificationMessageFormats.scala | 2 +- .../codec/JsonRpcRequestMessageFormats.scala | 2 +- .../codec/JsonRpcResponseErrorFormats.scala | 2 +- .../codec/JsonRpcResponseMessageFormats.scala | 5 +- run/src/main/scala/sbt/Fork.scala | 6 +- run/src/test/scala/sbt/ForkTest.scala | 2 +- .../sbt/internal/GrpcActionCacheStore.scala | 4 +- .../scala/sbt/plugins/RemoteCachePlugin.scala | 2 +- .../sbt/scriptedtest/ScriptedTests.scala | 4 +- .../test/scala/testpkg/BuildServerTest.scala | 8 +- .../src/test/scala/testpkg/EventsTest.scala | 4 +- .../test/scala/testpkg/HandshakeTest.scala | 4 +- .../src/test/scala/testpkg/ResponseTest.scala | 24 +- .../scala/testpkg/ServerCompletionsTest.scala | 4 +- .../src/test/scala/testpkg/TestServer.scala | 8 +- tasks-standard/src/main/scala/sbt/Task.scala | 2 +- .../src/main/scala/sbt/internal/Action.scala | 2 +- .../src/main/scala/sbt/std/TaskExtra.scala | 30 +-- .../src/main/scala/sbt/std/Transform.scala | 2 +- tasks-standard/src/test/scala/Execute.scala | 2 +- .../src/test/scala/TaskRunnerCircular.scala | 4 +- tasks-standard/src/test/scala/Test.scala | 6 +- .../src/test/scala/TestRunnerCall.scala | 2 +- .../scala/sbt/ConcurrentRestrictions.scala | 20 +- tasks/src/main/scala/sbt/Execute.scala | 8 +- .../src/main/scala/sbt/TestFramework.scala | 4 +- .../scala/sbt/util/ActionCacheStore.scala | 2 +- .../scala/sbt/util/BasicCacheImplicits.scala | 2 +- .../scala/sbt/internal/util/Attributes.scala | 34 +-- .../main/scala/sbt/internal/util/INode.scala | 30 +-- .../main/scala/sbt/internal/util/PMap.scala | 8 +- .../scala/sbt/internal/util/Settings.scala | 208 +++++++-------- .../src/test/scala/SettingsExample.scala | 4 +- .../src/main/scala/sbt/util/Tracked.scala | 5 +- .../src/test/scala/sbt/util/TrackedSpec.scala | 18 +- .../scala/sbt/internal/inc/ZincLmUtil.scala | 10 +- 211 files changed, 1592 insertions(+), 1527 deletions(-) diff --git a/build.sbt b/build.sbt index a539be898..2cb003575 100644 --- a/build.sbt +++ b/build.sbt @@ -1024,6 +1024,7 @@ lazy val sbtClientProj = (project in file("client")) Utils.noPublish, name := "sbt-client", mimaPreviousArtifacts := Set.empty, + bspEnabled := false, crossPaths := false, exportJars := true, libraryDependencies += jansi, diff --git a/buildfile/src/main/scala/sbt/internal/DslEntry.scala b/buildfile/src/main/scala/sbt/internal/DslEntry.scala index f451a055f..9292c2ea2 100644 --- a/buildfile/src/main/scala/sbt/internal/DslEntry.scala +++ b/buildfile/src/main/scala/sbt/internal/DslEntry.scala @@ -24,15 +24,15 @@ sealed trait DslEntry { object DslEntry { implicit def fromSettingsDef(inc: SettingsDefinition): DslEntry = DslSetting(inc) - implicit def fromSettingsDef(inc: Seq[Setting[_]]): DslEntry = + implicit def fromSettingsDef(inc: Seq[Setting[?]]): DslEntry = DslSetting(inc) /** Represents a DSL entry which adds settings to the current project. */ sealed trait ProjectSettings extends DslEntry { - def toSettings: Seq[Setting[_]] + def toSettings: Seq[Setting[?]] } object ProjectSettings { - def unapply(e: DslEntry): Option[Seq[Setting[_]]] = + def unapply(e: DslEntry): Option[Seq[Setting[?]]] = e match { case e: ProjectSettings => Some(e.toSettings) case _ => None @@ -62,26 +62,26 @@ object DslEntry { /** this represents an `enablePlugins()` in the sbt DSL */ case class DslEnablePlugins(plugins: Seq[AutoPlugin]) extends ProjectManipulation { - override val toFunction: Project => Project = _.enablePlugins(plugins: _*) + override val toFunction: Project => Project = _.enablePlugins(plugins*) } /** this represents an `disablePlugins()` in the sbt DSL */ case class DslDisablePlugins(plugins: Seq[AutoPlugin]) extends ProjectManipulation { - override val toFunction: Project => Project = _.disablePlugins(plugins: _*) + override val toFunction: Project => Project = _.disablePlugins(plugins*) } /** Represents registering an internal dependency for the current project */ case class DslDependsOn(cs: Seq[ClasspathDep[ProjectReference]]) extends ProjectManipulation { - override val toFunction: Project => Project = _.dependsOn(cs: _*) + override val toFunction: Project => Project = _.dependsOn(cs*) } /** Represents registering a set of configurations with the current project. */ case class DslConfigs(cs: Seq[Configuration]) extends ProjectManipulation { - override val toFunction: Project => Project = _.configs(cs: _*) + override val toFunction: Project => Project = _.configs(cs*) } /** this represents an `aggregateProjects()` in the sbt DSL */ case class DslAggregate(refs: Seq[ProjectReference]) extends ProjectManipulation { - override val toFunction: Project => Project = _.aggregate(refs: _*) + override val toFunction: Project => Project = _.aggregate(refs*) } } diff --git a/buildfile/src/main/scala/sbt/internal/Eval.scala b/buildfile/src/main/scala/sbt/internal/Eval.scala index 06ae18ae8..50bd140ad 100644 --- a/buildfile/src/main/scala/sbt/internal/Eval.scala +++ b/buildfile/src/main/scala/sbt/internal/Eval.scala @@ -382,7 +382,7 @@ object Eval: } def isTopLevelModule(sym: Symbols.Symbol)(using ctx: Context): Boolean = - (sym is Flags.Module) && (sym.owner is Flags.ModuleClass) + sym.is(Flags.Module) && sym.owner.is(Flags.ModuleClass) override def traverse(tree: tpd.Tree)(using ctx: Context): Unit = tree match diff --git a/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala b/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala index 6bc7c9ca0..4aa859018 100644 --- a/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala +++ b/buildfile/src/main/scala/sbt/internal/EvaluateConfigurations.scala @@ -77,7 +77,7 @@ private[sbt] object EvaluateConfigurations { } loader => loadFiles.foldLeft(LoadedSbtFile.empty) { (loaded, load) => - loaded merge load(loader) + loaded.merge(load(loader)) } } @@ -90,7 +90,7 @@ private[sbt] object EvaluateConfigurations { eval: Eval, src: VirtualFile, imports: Seq[String] - ): LazyClassLoaded[Seq[Setting[_]]] = + ): LazyClassLoaded[Seq[Setting[?]]] = evaluateConfiguration(eval, src, IO.readStream(src.input()).linesIterator.toList, imports, 0) /** @@ -129,7 +129,7 @@ private[sbt] object EvaluateConfigurations { lines: Seq[String], imports: Seq[String], offset: Int - ): LazyClassLoaded[Seq[Setting[_]]] = { + ): LazyClassLoaded[Seq[Setting[?]]] = { val l = evaluateSbtFile(eval, file, lines, imports, offset) loader => l(loader).settings } @@ -206,7 +206,7 @@ private[sbt] object EvaluateConfigurations { lines.map { case (s, i) => (s, i + offset) } def addOffsetToRange(offset: Int, ranges: Seq[(String, LineRange)]): Seq[(String, LineRange)] = - ranges.map { case (s, r) => (s, r shift offset) } + ranges.map { case (s, r) => (s, r.shift(offset)) } /** * The name of the class we cast DSL "setting" (vs. definition) lines to. @@ -254,7 +254,7 @@ private[sbt] object EvaluateConfigurations { TrackedEvalResult( result.generated, loader => { - val pos = RangePosition(name, range shift 1) + val pos = RangePosition(name, range.shift(1)) result.getValue(loader).asInstanceOf[DslEntry].withPos(pos) } ) @@ -281,7 +281,7 @@ private[sbt] object EvaluateConfigurations { imports: Seq[(String, Int)], expression: String, range: LineRange - ): LazyClassLoaded[Seq[Setting[_]]] = + ): LazyClassLoaded[Seq[Setting[?]]] = evaluateDslEntry(eval, name, imports, expression, range).result andThen { case DslEntry.ProjectSettings(values) => values case _ => Nil @@ -307,15 +307,15 @@ private[sbt] object EvaluateConfigurations { private def isDefinition(line: String): Boolean = { val trimmed = line.trim - DefinitionKeywords.exists(trimmed startsWith _) + DefinitionKeywords.exists(trimmed.startsWith(_)) } private def extractedValTypes: Seq[String] = Seq( classOf[CompositeProject], - classOf[InputKey[_]], - classOf[TaskKey[_]], - classOf[SettingKey[_]] + classOf[InputKey[?]], + classOf[TaskKey[?]], + classOf[SettingKey[?]] ).map(_.getName) private def evaluateDefinitions( @@ -351,19 +351,19 @@ object BuildUtilLite: end BuildUtilLite object Index { - def taskToKeyMap(data: Settings[Scope]): Map[Task[_], ScopedKey[Task[_]]] = { + def taskToKeyMap(data: Settings[Scope]): Map[Task[?], ScopedKey[Task[?]]] = { val pairs = data.scopes flatMap (scope => data.data(scope).entries collect { case AttributeEntry(key, value: Task[_]) => - (value, ScopedKey(scope, key.asInstanceOf[AttributeKey[Task[_]]])) + (value, ScopedKey(scope, key.asInstanceOf[AttributeKey[Task[?]]])) } ) - pairs.toMap[Task[_], ScopedKey[Task[_]]] + pairs.toMap[Task[?], ScopedKey[Task[?]]] } - def allKeys(settings: Seq[Setting[_]]): Set[ScopedKey[_]] = { - val result = new java.util.HashSet[ScopedKey[_]] + def allKeys(settings: Seq[Setting[?]]): Set[ScopedKey[?]] = { + val result = new java.util.HashSet[ScopedKey[?]] settings.foreach { s => if (!s.key.key.isLocal && result.add(s.key)) { s.dependencies.foreach(k => if (!k.key.isLocal) result.add(s.key)) @@ -372,15 +372,15 @@ object Index { result.asScala.toSet } - def attributeKeys(settings: Settings[Scope]): Set[AttributeKey[_]] = - settings.data.values.flatMap(_.keys).toSet[AttributeKey[_]] + def attributeKeys(settings: Settings[Scope]): Set[AttributeKey[?]] = + settings.data.values.flatMap(_.keys).toSet[AttributeKey[?]] - def stringToKeyMap(settings: Set[AttributeKey[_]]): Map[String, AttributeKey[_]] = + def stringToKeyMap(settings: Set[AttributeKey[?]]): Map[String, AttributeKey[?]] = stringToKeyMap0(settings)(_.label) private def stringToKeyMap0( - settings: Set[AttributeKey[_]] - )(label: AttributeKey[_] => String): Map[String, AttributeKey[_]] = { + settings: Set[AttributeKey[?]] + )(label: AttributeKey[?] => String): Map[String, AttributeKey[?]] = { val multiMap = settings.groupBy(label) val duplicates = multiMap.iterator .collect { case (k, xs) if xs.size > 1 => (k, xs.map(_.tag)) } diff --git a/buildfile/src/main/scala/sbt/internal/LoadedSbtFile.scala b/buildfile/src/main/scala/sbt/internal/LoadedSbtFile.scala index 07eed441e..c35d31001 100644 --- a/buildfile/src/main/scala/sbt/internal/LoadedSbtFile.scala +++ b/buildfile/src/main/scala/sbt/internal/LoadedSbtFile.scala @@ -17,7 +17,7 @@ import java.nio.file.Path * the values of Project vals, and the import statements for all defined vals/defs. */ private[sbt] final class LoadedSbtFile( - val settings: Seq[Setting[_]], + val settings: Seq[Setting[?]], val projects: Seq[Project], val importedDefs: Seq[String], val manipulations: Seq[Project => Project], @@ -33,7 +33,7 @@ private[sbt] final class LoadedSbtFile( projects ++ o.projects, importedDefs ++ o.importedDefs, manipulations, - definitions zip o.definitions, + definitions.zip(o.definitions), generatedFiles ++ o.generatedFiles ) @@ -48,7 +48,7 @@ private[sbt] final class LoadedSbtFile( private[sbt] final class DefinedSbtValues(val sbtFiles: Seq[EvalDefinitions]) { def values(parent: ClassLoader): Seq[Any] = - sbtFiles flatMap (_ values parent) + sbtFiles flatMap (_.values(parent)) def classloader(parent: ClassLoader): ClassLoader = sbtFiles.foldLeft(parent) { (cl, e) => diff --git a/buildfile/src/main/scala/sbt/internal/parser/SbtRefactorings.scala b/buildfile/src/main/scala/sbt/internal/parser/SbtRefactorings.scala index de16a4487..6817cb85e 100644 --- a/buildfile/src/main/scala/sbt/internal/parser/SbtRefactorings.scala +++ b/buildfile/src/main/scala/sbt/internal/parser/SbtRefactorings.scala @@ -17,7 +17,7 @@ private[sbt] object SbtRefactorings: import sbt.internal.parser.SbtParser.{ END_OF_LINE, FAKE_FILE } /** A session setting is simply a tuple of a Setting[_] and the strings which define it. */ - type SessionSetting = (Def.Setting[_], Seq[String]) + type SessionSetting = (Def.Setting[?], Seq[String]) val emptyString = "" val reverseOrderingInt = Ordering[Int].reverse diff --git a/client/src/main/java/sbt/client/Client.java b/client/src/main/java/sbt/client/Client.java index 6ffe838ff..00e1d6ff8 100644 --- a/client/src/main/java/sbt/client/Client.java +++ b/client/src/main/java/sbt/client/Client.java @@ -13,7 +13,7 @@ import java.nio.file.Paths; import org.fusesource.jansi.AnsiConsole; public class Client { - public static void main(final String[] args) { + public static void main(String[] args) { boolean isWin = System.getProperty("os.name").toLowerCase().startsWith("win"); try { if (isWin) AnsiConsole.systemInstall(); diff --git a/core-macros/src/main/scala/sbt/internal/util/appmacro/Cont.scala b/core-macros/src/main/scala/sbt/internal/util/appmacro/Cont.scala index 41fb9cc5e..4adeb0c35 100644 --- a/core-macros/src/main/scala/sbt/internal/util/appmacro/Cont.scala +++ b/core-macros/src/main/scala/sbt/internal/util/appmacro/Cont.scala @@ -337,7 +337,7 @@ trait Cont: summon[HashWriter[Unit]] }.asExprOf[HashWriter[A2]] else summonHashWriter[A2] - val tagsExpr = '{ List(${ Varargs(tags.map(Expr[CacheLevelTag](_))) }: _*) } + val tagsExpr = '{ List(${ Varargs(tags.map(Expr[CacheLevelTag](_))) }*) } val block = letOutput(outputs, cacheConfigExpr)(body) '{ given HashWriter[A2] = $inputHashWriter @@ -374,7 +374,7 @@ trait Cont: outputs = List(${ Varargs[VirtualFile](outputs.map: out => out.toRef.asExprOf[VirtualFile]) - }: _*), + }*), ) }.asTerm ).asExprOf[ActionCache.InternalActionResult[A1]] diff --git a/core-macros/src/main/scala/sbt/internal/util/appmacro/Convert.scala b/core-macros/src/main/scala/sbt/internal/util/appmacro/Convert.scala index b8e40f5c9..2c869081e 100644 --- a/core-macros/src/main/scala/sbt/internal/util/appmacro/Convert.scala +++ b/core-macros/src/main/scala/sbt/internal/util/appmacro/Convert.scala @@ -28,7 +28,7 @@ trait Convert[C <: Quotes & Singleton] extends ContextUtil[C]: (n: String, tpe: TypeRepr, tree: Term) => tpe.asType match case '[a] => - convert[a](n, tree)(Type.of[a]).isSuccess + convert[a](n, tree)(using Type.of[a]).isSuccess /** * Substitutes wrappers in tree `t` with the result of `subWrapper`. A wrapper is a Tree of the diff --git a/dependency-tree/src/main/scala/sbt/plugins/DependencyTreePlugin.scala b/dependency-tree/src/main/scala/sbt/plugins/DependencyTreePlugin.scala index bbe154376..a1e93a3aa 100644 --- a/dependency-tree/src/main/scala/sbt/plugins/DependencyTreePlugin.scala +++ b/dependency-tree/src/main/scala/sbt/plugins/DependencyTreePlugin.scala @@ -20,7 +20,7 @@ object DependencyTreePlugin extends AutoPlugin { val configurations = Vector(Compile, Test, IntegrationTest, Runtime, Provided, Optional) // MiniDependencyTreePlugin provides baseBasicReportingSettings for Compile and Test - override def projectSettings: Seq[Def.Setting[_]] = + override def projectSettings: Seq[Def.Setting[?]] = ((configurations diff Vector(Compile, Test)) flatMap { config => inConfig(config)(DependencyTreeSettings.baseBasicReportingSettings) }) ++ diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/LineReader.scala b/internal/util-complete/src/main/scala/sbt/internal/util/LineReader.scala index 1e2d055b5..2c0f1fee4 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/LineReader.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/LineReader.scala @@ -42,7 +42,7 @@ object LineReader { !java.lang.Boolean.getBoolean("sbt.disable.cont") && Signals.supported(Signals.CONT) val MaxHistorySize = 500 - private def completer(parser: Parser[_]): Completer = new Completer { + private def completer(parser: Parser[?]): Completer = new Completer { def complete(lr: JLineReader, pl: ParsedLine, candidates: JList[Candidate]): Unit = { Parser.completions(parser, pl.line(), 10).get.foreach { c => /* @@ -99,7 +99,7 @@ object LineReader { inputrcFileUrl().map(in => sbt.io.IO.readBytes(in.openStream())) def createReader( historyPath: Option[File], - parser: Parser[_], + parser: Parser[?], terminal: Terminal, ): LineReader = { // We may want to consider insourcing LineReader.java from jline. We don't otherwise @@ -291,14 +291,14 @@ private[sbt] object JLine { final class FullReader( historyPath: Option[File], - complete: Parser[_], + complete: Parser[?], val handleCONT: Boolean, terminal: Terminal ) extends JLine { @deprecated("Use the constructor with no injectThreadSleep parameter", "1.4.0") def this( historyPath: Option[File], - complete: Parser[_], + complete: Parser[?], handleCONT: Boolean = LineReader.HandleCONT, injectThreadSleep: Boolean = false ) = diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/Completions.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/Completions.scala index a65b161c8..99f6ed088 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/Completions.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/Completions.scala @@ -16,7 +16,7 @@ package complete sealed trait Completions { def get: Set[Completion] - final def x(o: Completions): Completions = flatMap(_ x o) + final infix def x(o: Completions): Completions = flatMap(_ x o) final def ++(o: Completions): Completions = Completions(get ++ o.get) final def +:(o: Completion): Completions = Completions(get + o) final def filter(f: Completion => Boolean): Completions = Completions(get filter f) @@ -90,8 +90,9 @@ sealed trait Completion { /** Appends the completions in `o` with the completions in this Completion. */ def ++(o: Completion): Completion = Completion.concat(this, o) - final def x(o: Completions): Completions = - if (Completion evaluatesRight this) o.map(this ++ _) else Completions.strict(Set.empty + this) + final infix def x(o: Completions): Completions = + if Completion.evaluatesRight(this) then o.map(this ++ _) + else Completions.strict(Set.empty + this) override final lazy val hashCode = Completion.hashCode(this) override final def equals(o: Any) = o match { diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/ExampleSource.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/ExampleSource.scala index ddb7bc101..bced54930 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/ExampleSource.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/ExampleSource.scala @@ -49,7 +49,7 @@ sealed case class FixedSetExamples(examples: Iterable[String]) extends ExampleSo override def apply(): Iterable[String] = examples private def examplesWithRemovedPrefix(prefix: String) = examples.collect { - case example if example startsWith prefix => example substring prefix.length + case example if example.startsWith(prefix) => example.substring(prefix.length) } } @@ -79,5 +79,5 @@ class FileExamples(base: File, prefix: String = "") extends ExampleSource { } private def dirStartsWithPrefix(relativizedPath: String): Boolean = - (relativizedPath startsWith prefix) || (prefix startsWith relativizedPath) + relativizedPath.startsWith(prefix) || prefix.startsWith(relativizedPath) } diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala index 9f265a048..a7c7fec29 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/JLineCompletion.scala @@ -15,7 +15,7 @@ import scala.annotation.tailrec import scala.jdk.CollectionConverters.* object JLineCompletion { - def installCustomCompletor(reader: ConsoleReader, parser: Parser[_]): Unit = + def installCustomCompletor(reader: ConsoleReader, parser: Parser[?]): Unit = installCustomCompletor(reader)(parserAsCompletor(parser)) def installCustomCompletor(reader: ConsoleReader)( @@ -64,12 +64,12 @@ object JLineCompletion { cursor: Int, candidates: java.util.List[CharSequence] ): Int = { - candidates.asInstanceOf[java.util.List[String]] add "dummy" + candidates.asInstanceOf[java.util.List[String]].add("dummy") 0 } } - def parserAsCompletor(p: Parser[_]): (String, Int) => (Seq[String], Seq[String]) = + def parserAsCompletor(p: Parser[?]): (String, Int) => (Seq[String], Seq[String]) = (str, level) => convertCompletions(Parser.completions(p, str, level)) def convertCompletions(c: Completions): (Seq[String], Seq[String]) = { diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parser.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parser.scala index 6bc9b8524..bf8a91390 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parser.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parser.scala @@ -100,7 +100,7 @@ sealed trait RichParser[A] { * Apply the original parser, but only succeed if `o` also succeeds. Note that `o` does not need * to consume the same amount of input to satisfy this condition. */ - def &(o: Parser[_]): Parser[A] + def &(o: Parser[?]): Parser[A] /** Explicitly defines the completions for the original Parser. */ def examples(s: String*): Parser[A] @@ -160,11 +160,11 @@ object Parser extends ParserMain: def isFailure: Boolean def isValid: Boolean def errors: Seq[String] - def or[B >: T](b: => Result[B]): Result[B] + infix def or[B >: T](b: => Result[B]): Result[B] def either[B](b: => Result[B]): Result[Either[T, B]] def map[B](f: T => B): Result[B] def flatMap[B](f: T => Result[B]): Result[B] - def &&(b: => Result[_]): Result[T] + infix def &&(b: => Result[?]): Result[T] def filter(f: T => Boolean, msg: => String): Result[T] def seq[B](b: => Result[B]): Result[(T, B)] = app(b)((m, n) => (m, n)) def app[B, C](b: => Result[B])(f: (T, B) => C): Result[C] @@ -181,8 +181,8 @@ object Parser extends ParserMain: case Value(bv) => Value(f(value, bv)) } - def &&(b: => Result[_]): Result[T] = b match { case f: Failure => f; case _ => this } - def or[B >: T](b: => Result[B]): Result[B] = this + infix def &&(b: => Result[?]): Result[T] = b match { case f: Failure => f; case _ => this } + infix def or[B >: T](b: => Result[B]): Result[B] = this def either[B](b: => Result[B]): Result[Either[T, B]] = Value(Left(value)) def map[B](f: T => B): Result[B] = Value(f(value)) def flatMap[B](f: T => Result[B]): Result[B] = f(value) @@ -198,7 +198,7 @@ object Parser extends ParserMain: def map[B](f: Nothing => B) = this def flatMap[B](f: Nothing => Result[B]) = this - def or[B](b: => Result[B]): Result[B] = b match { + infix def or[B](b: => Result[B]): Result[B] = b match { case v: Value[B] => v case f: Failure => if (definitive) this else this ++ f } @@ -210,7 +210,7 @@ object Parser extends ParserMain: def filter(f: Nothing => Boolean, msg: => String) = this def app[B, C](b: => Result[B])(f: (Nothing, B) => C): Result[C] = this - def &&(b: => Result[_]) = this + infix def &&(b: => Result[?]) = this def toEither = Left(() => errors) private[sbt] def ++(f: Failure) = mkFailures(errors ++ f.errors) @@ -263,8 +263,8 @@ object Parser extends ParserMain: b.ifValid { (a.result, b.result) match { case (Some(av), Some(bv)) => success((av, bv)) - case (Some(av), None) => b map (bv => (av, bv)) - case (None, Some(bv)) => a map (av => (av, bv)) + case (Some(av), None) => b.map(bv => (av, bv)) + case (None, Some(bv)) => a.map(av => (av, bv)) case (None, None) => new SeqParser(a, b) } } @@ -332,7 +332,7 @@ object Parser extends ParserMain: } } - def and[T](a: Parser[T], b: Parser[_]): Parser[T] = a.ifValid(b.ifValid(new And(a, b))) + def and[T](a: Parser[T], b: Parser[?]): Parser[T] = a.ifValid(b.ifValid(new And(a, b))) end Parser @@ -349,7 +349,7 @@ trait ParserMain { def map[B](f: A => B) = mapParser(a, f) def id = a - def ^^^[B](value: B): Parser[B] = a map (_ => value) + def ^^^[B](value: B): Parser[B] = a.map(_ => value) def ??[B >: A](alt: B): Parser[B] = a.? map { x => x.getOrElse[B](alt) } @@ -358,7 +358,7 @@ trait ParserMain { def !!!(msg: String): Parser[A] = onFailure(a, msg) def failOnException: Parser[A] = trapAndFail(a) - def &(o: Parser[_]) = and(a, o) + def &(o: Parser[?]) = and(a, o) def examples(s: String*): Parser[A] = examples(s.toSet) def examples(s: Set[String], check: Boolean = false): Parser[A] = @@ -424,12 +424,12 @@ trait ParserMain { * Presents a Char range as a Parser. A single Char is parsed only if it is in the given range. */ def range(r: collection.immutable.NumericRange[Char], label: String): Parser[Char] = - charClass(r contains _, label).examples(r.map(_.toString): _*) + charClass(r contains _, label).examples(r.map(_.toString)*) /** Defines a Parser that parses a single character only if it is contained in `legal`. */ def chars(legal: String): Parser[Char] = { val set = legal.toSet - charClass(set, "character in '" + legal + "'") examples (set.map(_.toString)) + charClass(set, "character in '" + legal + "'").examples(set.map(_.toString)) } /** @@ -481,7 +481,7 @@ trait ParserMain { * * See also [[sampleParse]] and [[sampleCompletions]]. */ - def sample(str: String, parser: Parser[_], completions: Boolean = false): Unit = + def sample(str: String, parser: Parser[?], completions: Boolean = false): Unit = if (completions) sampleCompletions(str, parser) else sampleParse(str, parser) /** @@ -489,7 +489,7 @@ trait ParserMain { * the result of parsing is printed using the result's `toString` method. If parsing fails, the * error message is displayed. */ - def sampleParse(str: String, parser: Parser[_]): Unit = + def sampleParse(str: String, parser: Parser[?]): Unit = parse(str, parser) match { case Left(msg) => println(msg) case Right(v) => println(v) @@ -500,7 +500,7 @@ trait ParserMain { * the available completions are displayed on separate lines. If parsing fails, the error message * is displayed. */ - def sampleCompletions(str: String, parser: Parser[_], level: Int = 1): Unit = + def sampleCompletions(str: String, parser: Parser[?], level: Int = 1): Unit = Parser.completions(parser, str, level).get foreach println // intended to be temporary pending proper error feedback @@ -517,7 +517,7 @@ trait ParserMain { (nonEmpty, ci) } else - loop(ci, a derive s(ci)) + loop(ci, a.derive(s((ci)))) } loop(-1, p) } @@ -536,9 +536,9 @@ trait ParserMain { * increasing positive numbers corresponding to increasing verbosity. Typically no more than a few * levels are defined. */ - def completions(p: Parser[_], s: String, level: Int): Completions = + def completions(p: Parser[?], s: String, level: Int): Completions = // The x Completions.empty removes any trailing token completions where append.isEmpty - apply(p)(s).completions(level) x Completions.empty + apply(p)(s).completions(level).x(Completions.empty) def examples[A](a: Parser[A], completions: Set[String], check: Boolean = false): Parser[A] = examples(a, new FixedSetExamples(completions), completions.size, check) @@ -575,7 +575,7 @@ trait ParserMain { } else a def matched( - t: Parser[_], + t: Parser[?], seen: Vector[Char] = Vector.empty, partial: Boolean = false ): Parser[String] = @@ -636,7 +636,7 @@ trait ParserMain { case (_, _) => new HomParser(a, b) } - def not(p: Parser[_], failMessage: String): Parser[Unit] = p.result match { + def not(p: Parser[?], failMessage: String): Parser[Unit] = p.result match { case None => new Not(p, failMessage) case Some(_) => failure(failMessage) } @@ -698,7 +698,7 @@ private final class TrapAndFail[A](a: Parser[A]) extends ValidParser[A] { def derive(c: Char) = try { - trapAndFail(a derive c) + trapAndFail(a.derive(c)) } catch { case e: Exception => Invalid(fail(e)) } @@ -722,7 +722,7 @@ private final class OnFailure[A](a: Parser[A], message: String) extends ValidPar case _: Failure => mkFailure(message); case v: Value[A] => v } - def derive(c: Char) = onFailure(a derive c, message) + def derive(c: Char) = onFailure(a.derive(c), message) def completions(level: Int) = a.completions(level) override def toString = "(" + a + " !!! \"" + message + "\" )" override def isTokenStart = a.isTokenStart @@ -730,7 +730,7 @@ private final class OnFailure[A](a: Parser[A], message: String) extends ValidPar private final class SeqParser[A, B](a: Parser[A], b: Parser[B]) extends ValidParser[(A, B)] { lazy val result = tuple(a.result, b.result) - lazy val resultEmpty = a.resultEmpty seq b.resultEmpty + lazy val resultEmpty = a.resultEmpty.seq(b.resultEmpty) def derive(c: Char) = { val common = a.derive(c) ~ b @@ -740,13 +740,13 @@ private final class SeqParser[A, B](a: Parser[A], b: Parser[B]) extends ValidPar } } - def completions(level: Int) = a.completions(level) x b.completions(level) + def completions(level: Int) = a.completions(level).x(b.completions(level)) override def toString = "(" + a + " ~ " + b + ")" } private final class HomParser[A](a: Parser[A], b: Parser[A]) extends ValidParser[A] { lazy val result = tuple(a.result, b.result) map (_._1) - def derive(c: Char) = (a derive c) | (b derive c) + def derive(c: Char) = a.derive(c) | b.derive(c) lazy val resultEmpty = a.resultEmpty or b.resultEmpty def completions(level: Int) = a.completions(level) ++ b.completions(level) override def toString = "(" + a + " | " + b + ")" @@ -754,8 +754,8 @@ private final class HomParser[A](a: Parser[A], b: Parser[A]) extends ValidParser private final class HetParser[A, B](a: Parser[A], b: Parser[B]) extends ValidParser[Either[A, B]] { lazy val result = tuple(a.result, b.result) map { case (a, _) => Left(a) } - def derive(c: Char) = (a derive c) || (b derive c) - lazy val resultEmpty = a.resultEmpty either b.resultEmpty + def derive(c: Char) = a.derive(c) || b.derive(c) + lazy val resultEmpty = a.resultEmpty.either(b.resultEmpty) def completions(level: Int) = a.completions(level) ++ b.completions(level) override def toString = "(" + a + " || " + b + ")" } @@ -777,25 +777,25 @@ private final class ParserSeq[T](a: Seq[Parser[T]], errors: => Seq[String]) } def completions(level: Int) = a.map(_.completions(level)).reduceLeft(_ ++ _) - def derive(c: Char) = seq0(a.map(_ derive c), errors) + def derive(c: Char) = seq0(a.map(_.derive(c)), errors) override def toString = "seq(" + a + ")" } private final class BindParser[A, B](a: Parser[A], f: A => Parser[B]) extends ValidParser[B] { lazy val result = a.result flatMap (av => f(av).result) - lazy val resultEmpty = a.resultEmpty flatMap (av => f(av).resultEmpty) + lazy val resultEmpty = a.resultEmpty.flatMap(av => f(av).resultEmpty) def completions(level: Int) = a.completions(level) flatMap { c => apply(a)(c.append).resultEmpty match { case _: Failure => Completions.strict(Set.empty + c) - case Value(av) => c x f(av).completions(level) + case Value(av) => c.x(f(av).completions(level)) } } def derive(c: Char) = { - val common = a derive c flatMap f + val common = a.derive(c).flatMap(f) a.resultEmpty match { case Value(av) => common | derive1(f(av), c) case _: Failure => common @@ -809,8 +809,8 @@ private final class BindParser[A, B](a: Parser[A], f: A => Parser[B]) extends Va private final class MapParser[A, B](a: Parser[A], f: A => B) extends ValidParser[B] { lazy val result = a.result map f - lazy val resultEmpty = a.resultEmpty map f - def derive(c: Char) = (a derive c) map f + lazy val resultEmpty = a.resultEmpty.map(f) + def derive(c: Char) = a.derive(c).map(f) def completions(level: Int) = a.completions(level) override def isTokenStart = a.isTokenStart override def toString = "map(" + a + ")" @@ -822,7 +822,7 @@ private final class Filter[T](p: Parser[T], f: T => Boolean, seen: String, msg: def filterResult(r: Result[T]) = r.filter(f, msg(seen)) lazy val result = p.result filter f lazy val resultEmpty = filterResult(p.resultEmpty) - def derive(c: Char) = filterParser(p derive c, f, seen + c, msg) + def derive(c: Char) = filterParser(p.derive(c), f, seen + c, msg) def completions(level: Int) = p.completions(level) filterS { s => filterResult(apply(p)(s).resultEmpty).isValid @@ -832,10 +832,10 @@ private final class Filter[T](p: Parser[T], f: T => Boolean, seen: String, msg: override def isTokenStart = p.isTokenStart } -private final class MatchedString(delegate: Parser[_], seenV: Vector[Char], partial: Boolean) +private final class MatchedString(delegate: Parser[?], seenV: Vector[Char], partial: Boolean) extends ValidParser[String] { lazy val seen = seenV.mkString - def derive(c: Char) = matched(delegate derive c, seenV :+ c, partial) + def derive(c: Char) = matched(delegate.derive(c), seenV :+ c, partial) def completions(level: Int) = delegate.completions(level) def result = if (delegate.result.isDefined) Some(seen) else None @@ -849,7 +849,7 @@ private final class MatchedString(delegate: Parser[_], seenV: Vector[Char], part private final class TokenStart[T](delegate: Parser[T], seen: String, complete: TokenCompletions) extends ValidParser[T] { - def derive(c: Char) = mkToken(delegate derive c, seen + c, complete) + def derive(c: Char) = mkToken(delegate.derive(c), seen + c, complete) def completions(level: Int) = complete match { case dc: TokenCompletions.Delegating => @@ -863,16 +863,16 @@ private final class TokenStart[T](delegate: Parser[T], seen: String, complete: T override def toString = "token('" + complete + ", " + delegate + ")" } -private final class And[T](a: Parser[T], b: Parser[_]) extends ValidParser[T] { +private final class And[T](a: Parser[T], b: Parser[?]) extends ValidParser[T] { lazy val result = tuple(a.result, b.result) map { _._1 } - def derive(c: Char) = (a derive c) & (b derive c) + def derive(c: Char) = a.derive(c) & b.derive(c) def completions(level: Int) = a.completions(level).filterS(s => apply(b)(s).resultEmpty.isValid) lazy val resultEmpty = a.resultEmpty && b.resultEmpty override def toString = "(%s) && (%s)".format(a, b) } -private final class Not(delegate: Parser[_], failMessage: String) extends ValidParser[Unit] { - def derive(c: Char) = if (delegate.valid) not(delegate derive c, failMessage) else this +private final class Not(delegate: Parser[?], failMessage: String) extends ValidParser[Unit] { + def derive(c: Char) = if (delegate.valid) not(delegate.derive(c), failMessage) else this def completions(level: Int) = Completions.empty def result = None @@ -914,7 +914,7 @@ private final class ParserWithExamples[T]( def derive(c: Char) = examples( - delegate derive c, + delegate.derive(c), exampleSource.withAddedPrefix(c.toString), maxNumberOfExamples, removeInvalidExamples @@ -973,7 +973,7 @@ private final class CharacterClass(f: Char => Boolean, label: String) extends Va private final class Optional[A](delegate: Parser[A]) extends ValidParser[Option[A]] { def result = delegate.result.map(some[A]) def resultEmpty = Value(None) - def derive(c: Char) = (delegate derive c).map(some[A]) + def derive(c: Char) = delegate.derive(c).map(some[A]) def completions(level: Int) = Completion.empty +: delegate.completions(level) override def toString = delegate.toString + "?" } @@ -991,7 +991,7 @@ private final class Repeat[T]( def derive(c: Char) = partial match { case Some(part) => - val partD = repeat(Some(part derive c), repeated, min, max, accumulatedReverse) + val partD = repeat(Some(part.derive(c)), repeated, min, max, accumulatedReverse) part.resultEmpty match { case Value(pv) => partD | repeatDerive(c, pv :: accumulatedReverse) case _: Failure => partD @@ -1000,16 +1000,16 @@ private final class Repeat[T]( } def repeatDerive(c: Char, accRev: List[T]): Parser[Seq[T]] = - repeat(Some(repeated derive c), repeated, scala.math.max(0, min - 1), max.decrement, accRev) + repeat(Some(repeated.derive(c)), repeated, scala.math.max(0, min - 1), max.decrement, accRev) def completions(level: Int) = { def pow(comp: Completions, exp: Completions, n: Int): Completions = - if (n == 1) comp else pow(comp x exp, exp, n - 1) + if (n == 1) comp else pow(comp.x(exp), exp, n - 1) val repC = repeated.completions(level) val fin = if (min == 0) Completion.empty +: repC else pow(repC, repC, min) partial match { - case Some(p) => p.completions(level) x fin + case Some(p) => p.completions(level).x(fin) case None => fin } } @@ -1023,7 +1023,7 @@ private final class Repeat[T]( case Some(partialPattern) => partialPattern.resultEmpty.map(_ :: accumulatedReverse) } - (partialAccumulatedOption app repeatedParseEmpty)((x, y) => (x reverse_::: y): Seq[T]) + (partialAccumulatedOption.app(repeatedParseEmpty))((x, y) => (x reverse_::: y): Seq[T]) } private def repeatedParseEmpty: Result[List[T]] = { diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parsers.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parsers.scala index 38c4b36ac..e18cd7143 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parsers.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/Parsers.scala @@ -38,16 +38,19 @@ trait Parsers { lazy val DigitSet = Set("0", "1", "2", "3", "4", "5", "6", "7", "8", "9") /** Parses any single digit and provides that digit as a Char as the result. */ - lazy val Digit = charClass(_.isDigit, "digit") examples DigitSet + lazy val Digit = charClass(_.isDigit, "digit").examples(DigitSet) /** Set containing Chars for hexadecimal digits 0-9 and A-F (but not a-f). */ lazy val HexDigitSet = Set('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F') /** Parses a single hexadecimal digit (0-9, a-f, A-F). */ - lazy val HexDigit = charClass(c => HexDigitSet(c.toUpper), "hex digit") examples HexDigitSet.map( - _.toString - ) + lazy val HexDigit = + charClass(c => HexDigitSet(c.toUpper), "hex digit").examples( + HexDigitSet.map( + _.toString + ) + ) /** Parses a single letter, according to Char.isLetter, into a Char. */ lazy val Letter = charClass(_.isLetter, "letter") @@ -322,14 +325,14 @@ trait Parsers { * Applies `rep` zero or more times, separated by `sep`. The result is the (possibly empty) * sequence of results from the multiple `rep` applications. The `sep` results are discarded. */ - def repsep[T](rep: Parser[T], sep: Parser[_]): Parser[Seq[T]] = + def repsep[T](rep: Parser[T], sep: Parser[?]): Parser[Seq[T]] = rep1sep(rep, sep) ?? nilSeq[T] /** * Applies `rep` one or more times, separated by `sep`. The result is the non-empty sequence of * results from the multiple `rep` applications. The `sep` results are discarded. */ - def rep1sep[T](rep: Parser[T], sep: Parser[_]): Parser[Seq[T]] = + def rep1sep[T](rep: Parser[T], sep: Parser[?]): Parser[Seq[T]] = (rep ~ (sep ~> rep).*).map { case (x ~ xs) => x +: xs } /** Wraps the result of `p` in `Some`. */ @@ -390,7 +393,7 @@ trait Parsers { * Parses a URI that is valid according to the single argument java.net.URI constructor, using * `ex` as tab completion examples. */ - def Uri(ex: Set[URI]) = basicUri examples (ex.map(_.toString)) + def Uri(ex: Set[URI]) = basicUri.examples(ex.map(_.toString)) } /** Provides standard [[Parser]] implementations. */ @@ -400,7 +403,7 @@ object Parsers extends Parsers object DefaultParsers extends Parsers with ParserMain { /** Applies parser `p` to input `s` and returns `true` if the parse was successful. */ - def matches(p: Parser[_], s: String): Boolean = + def matches(p: Parser[?], s: String): Boolean = apply(p)(s).resultEmpty.isValid /** Returns `true` if `s` parses successfully according to [[ID]]. */ diff --git a/internal/util-complete/src/main/scala/sbt/internal/util/complete/ProcessError.scala b/internal/util-complete/src/main/scala/sbt/internal/util/complete/ProcessError.scala index e26eebfc9..4e78b7061 100644 --- a/internal/util-complete/src/main/scala/sbt/internal/util/complete/ProcessError.scala +++ b/internal/util-complete/src/main/scala/sbt/internal/util/complete/ProcessError.scala @@ -19,7 +19,7 @@ object ProcessError { def extractLine(s: String, i: Int): (String, Int) = { val notNewline = (c: Char) => c != '\n' && c != '\r' val left = takeRightWhile(s.substring(0, i))(notNewline) - val right = s substring i takeWhile notNewline + val right = s.substring(i).takeWhile(notNewline) (left + right, left.length) } diff --git a/internal/util-complete/src/test/scala/ParserTest.scala b/internal/util-complete/src/test/scala/ParserTest.scala index 2bc1688aa..a884afc70 100644 --- a/internal/util-complete/src/test/scala/ParserTest.scala +++ b/internal/util-complete/src/test/scala/ParserTest.scala @@ -62,10 +62,10 @@ object ParserTest extends Properties("Completing Parser") { (("token '" + in + "'") |: checkOne(in, nested, expect)) && (("display '" + in + "'") |: checkOne(in, nestedDisplay, expectDisplay)) - def checkOne(in: String, parser: Parser[_], expect: Completion): Prop = + def checkOne(in: String, parser: Parser[?], expect: Completion): Prop = completions(parser, in, 1) == Completions.single(expect) - def checkAll(in: String, parser: Parser[_], expect: Completions): Prop = { + def checkAll(in: String, parser: Parser[?], expect: Completions): Prop = { val cs = completions(parser, in, 1) ("completions: " + cs) |: ("Expected: " + expect) |: (cs == expect: Prop) } @@ -74,7 +74,7 @@ object ParserTest extends Properties("Completing Parser") { (("token '" + in + "'") |: checkInv(in, nested)) && (("display '" + in + "'") |: checkInv(in, nestedDisplay)) - def checkInv(in: String, parser: Parser[_]): Prop = { + def checkInv(in: String, parser: Parser[?]): Prop = { val cs = completions(parser, in, 1) ("completions: " + cs) |: (cs == Completions.nil: Prop) } @@ -103,7 +103,7 @@ object ParserTest extends Properties("Completing Parser") { checkOne("asdf", token(any.+.examples("asdf", "qwer")), Completion.suggestion("")) val colors = Set("blue", "green", "red") - val base = (seen: Seq[String]) => token(ID examples (colors -- seen)) + val base = (seen: Seq[String]) => token(ID.examples(colors -- seen)) val sep = token(Space) val repeat = repeatDep(base, sep) def completionStrings(ss: Set[String]) = Completions(ss map (Completion.token("", _))) diff --git a/internal/util-complete/src/test/scala/sbt/complete/FileExamplesTest.scala b/internal/util-complete/src/test/scala/sbt/complete/FileExamplesTest.scala index a4106d952..204a85d20 100644 --- a/internal/util-complete/src/test/scala/sbt/complete/FileExamplesTest.scala +++ b/internal/util-complete/src/test/scala/sbt/complete/FileExamplesTest.scala @@ -70,12 +70,12 @@ class FileExamplesTest extends UnitSpec { } final class DirectoryStructure(withCompletionPrefix: String) { - var fileExamples: FileExamples = _ - var baseDir: File = _ - var childFiles: List[File] = _ - var childDirectories: List[File] = _ - var nestedFiles: List[File] = _ - var nestedDirectories: List[File] = _ + var fileExamples: FileExamples = scala.compiletime.uninitialized + var baseDir: File = scala.compiletime.uninitialized + var childFiles: List[File] = scala.compiletime.uninitialized + var childDirectories: List[File] = scala.compiletime.uninitialized + var nestedFiles: List[File] = scala.compiletime.uninitialized + var nestedDirectories: List[File] = scala.compiletime.uninitialized def allRelativizedPaths: List[String] = (childFiles ++ childDirectories ++ nestedFiles ++ nestedDirectories) @@ -83,8 +83,8 @@ class FileExamplesTest extends UnitSpec { def prefixedPathsOnly: List[String] = allRelativizedPaths - .withFilter(_ startsWith withCompletionPrefix) - .map(_ substring withCompletionPrefix.length) + .withFilter(_.startsWith(withCompletionPrefix)) + .map(_.substring(withCompletionPrefix.length)) def createSampleDirStructure(tempDir: File): Unit = { childFiles = toChildFiles(tempDir, List("foo", "bar", "bazaar")) diff --git a/internal/util-logging/src/main/scala/sbt/internal/util/BufferedLogger.scala b/internal/util-logging/src/main/scala/sbt/internal/util/BufferedLogger.scala index ff83d843d..de0120d57 100644 --- a/internal/util-logging/src/main/scala/sbt/internal/util/BufferedLogger.scala +++ b/internal/util-logging/src/main/scala/sbt/internal/util/BufferedLogger.scala @@ -68,7 +68,7 @@ class BufferedAppender(override val name: String, delegate: Appender) extends Ap } private val buffer = - new java.util.Vector[Either[XLogEvent, (Level.Value, Option[String], Option[ObjectEvent[_]])]] + new java.util.Vector[Either[XLogEvent, (Level.Value, Option[String], Option[ObjectEvent[?]])]] private var recording = false override def appendLog(level: Level.Value, message: => String): Unit = { diff --git a/internal/util-logging/src/main/scala/sbt/internal/util/ConsoleAppender.scala b/internal/util-logging/src/main/scala/sbt/internal/util/ConsoleAppender.scala index 5f14043ff..0b7d38720 100644 --- a/internal/util-logging/src/main/scala/sbt/internal/util/ConsoleAppender.scala +++ b/internal/util-logging/src/main/scala/sbt/internal/util/ConsoleAppender.scala @@ -600,7 +600,7 @@ trait Appender extends AutoCloseable { } private def appendMessageContent(level: Level.Value, o: AnyRef): Unit = { - def appendEvent(oe: ObjectEvent[_]): Unit = { + def appendEvent(oe: ObjectEvent[?]): Unit = { val contentType = oe.contentType contentType match { case "sbt.internal.util.TraceEvent" => appendTraceEvent(oe.message.asInstanceOf[TraceEvent]) diff --git a/internal/util-logging/src/main/scala/sbt/internal/util/Terminal.scala b/internal/util-logging/src/main/scala/sbt/internal/util/Terminal.scala index bcdfed879..e581d998f 100644 --- a/internal/util-logging/src/main/scala/sbt/internal/util/Terminal.scala +++ b/internal/util-logging/src/main/scala/sbt/internal/util/Terminal.scala @@ -256,7 +256,7 @@ object Terminal { * already wraps a jline terminal, so we can just return the wrapped jline * terminal. */ - private[sbt] def toJLine: jline.Terminal with jline.Terminal2 = term match { + private[sbt] def toJLine: jline.Terminal & jline.Terminal2 = term match { case _ => new jline.Terminal with jline.Terminal2 { override def init(): Unit = {} @@ -484,7 +484,7 @@ object Terminal { override private[sbt] def withRawOutput[R](f: => R): R = t.withRawOutput(f) override def restore(): Unit = t.restore() override def close(): Unit = {} - override private[sbt] def write(bytes: Int*): Unit = t.write(bytes: _*) + override private[sbt] def write(bytes: Int*): Unit = t.write(bytes*) override def getLastLine: Option[String] = t.getLastLine override def getLines: Seq[String] = t.getLines override private[sbt] def name: String = t.name @@ -1041,7 +1041,7 @@ object Terminal { override private[sbt] val printStream: PrintStream = new LinePrintStream(outputStream) override def inputStream: InputStream = in - private[sbt] def write(bytes: Int*): Unit = in.write(bytes: _*) + private[sbt] def write(bytes: Int*): Unit = in.write(bytes*) private val isStopped = new AtomicBoolean(false) override def getLineHeightAndWidth(line: String): (Int, Int) = getWidth match { diff --git a/internal/util-logging/src/main/scala/sbt/internal/util/codec/ProblemFormats.scala b/internal/util-logging/src/main/scala/sbt/internal/util/codec/ProblemFormats.scala index d81ae2425..b1006428f 100644 --- a/internal/util-logging/src/main/scala/sbt/internal/util/codec/ProblemFormats.scala +++ b/internal/util-logging/src/main/scala/sbt/internal/util/codec/ProblemFormats.scala @@ -12,7 +12,7 @@ import xsbti.{ Problem, Severity, Position } import _root_.sjsonnew.{ deserializationError, Builder, JsonFormat, Unbuilder } import java.util.Optional -trait ProblemFormats { self: SeverityFormats with PositionFormats with sjsonnew.BasicJsonProtocol => +trait ProblemFormats { self: SeverityFormats & PositionFormats & sjsonnew.BasicJsonProtocol => implicit lazy val ProblemFormat: JsonFormat[Problem] = new JsonFormat[Problem] { override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): Problem = { jsOpt match { diff --git a/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala b/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala index 9dd5e23ed..a499894a2 100644 --- a/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala +++ b/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala @@ -23,7 +23,7 @@ import scala.collection.concurrent sealed abstract class LogExchange { private[sbt] lazy val context: XLoggerContext = init() - private[sbt] val stringCodecs: concurrent.Map[String, ShowLines[_]] = concurrent.TrieMap() + private[sbt] val stringCodecs: concurrent.Map[String, ShowLines[?]] = concurrent.TrieMap() private[sbt] val builtInStringCodecs: Unit = initStringCodecs() private[util] val configs = new ConcurrentHashMap[String, LoggerConfig] private[util] def addConfig(name: String, config: LoggerConfig): Unit = diff --git a/internal/util-logic/src/main/scala/sbt/internal/util/logic/Logic.scala b/internal/util-logic/src/main/scala/sbt/internal/util/logic/Logic.scala index ca99ef320..25ea70856 100644 --- a/internal/util-logic/src/main/scala/sbt/internal/util/logic/Logic.scala +++ b/internal/util-logic/src/main/scala/sbt/internal/util/logic/Logic.scala @@ -248,9 +248,9 @@ object Logic { case None => state // all of the remaining clauses failed on the new facts case Some(applied) => val (proven, unprovenClauses) = findProven(applied) - val processedFacts = state add keepPositive(factsToProcess) + val processedFacts = state.add(keepPositive(factsToProcess)) val newlyProven = proven -- processedFacts.provenSet - val newState = processedFacts add newlyProven + val newState = processedFacts.add(newlyProven) if (unprovenClauses.isEmpty) newState // no remaining clauses, done. else { val unproven = Clauses(unprovenClauses) diff --git a/internal/util-relation/src/test/scala/RelationTest.scala b/internal/util-relation/src/test/scala/RelationTest.scala index 469e3fd4a..295562e63 100644 --- a/internal/util-relation/src/test/scala/RelationTest.scala +++ b/internal/util-relation/src/test/scala/RelationTest.scala @@ -57,7 +57,7 @@ object RelationTest extends Properties("Relation") { property("Groups correctly") = forAll { (entries: List[(Int, Double)], randomInt: Int) => val splitInto = math.abs(randomInt) % 10 + 1 // Split into 1-10 groups. val rel = Relation.empty[Int, Double] ++ entries - val grouped = rel groupBy (_._1 % splitInto) + val grouped = rel.groupBy(_._1 % splitInto) all(grouped.toSeq) { case (k, rel_k) => rel_k._1s forall { _ % splitInto == k } } diff --git a/internal/util-scripted/src/main/scala/sbt/internal/scripted/FileCommands.scala b/internal/util-scripted/src/main/scala/sbt/internal/scripted/FileCommands.scala index 5d4cdd26e..330a4681b 100644 --- a/internal/util-scripted/src/main/scala/sbt/internal/scripted/FileCommands.scala +++ b/internal/util-scripted/src/main/scala/sbt/internal/scripted/FileCommands.scala @@ -19,13 +19,13 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler { lazy val commands = commandMap def commandMap = Map( - "touch" nonEmpty touch _, - "delete" nonEmpty delete _, - "exists" nonEmpty exists _, - "mkdir" nonEmpty makeDirectories _, - "absent" nonEmpty absent _, + "touch".nonEmpty(touch), + "delete".nonEmpty(delete), + "exists".nonEmpty(exists), + "mkdir".nonEmpty(makeDirectories), + "absent".nonEmpty(absent), // "sync" twoArg("Two directory paths", sync _), - "newer".twoArg("Two paths", newer _), + "newer".twoArg("Two paths", newer), "pause" noArg { println("Pausing in " + baseDirectory) /*readLine("Press enter to continue. ") */ @@ -34,11 +34,11 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler { println() }, "sleep".oneArg("Time in milliseconds", time => Thread.sleep(time.toLong)), - "exec" nonEmpty (execute _), - "copy" copy (to => rebase(baseDirectory, to)), - "copy-file".twoArg("Two paths", copyFile _), - "must-mirror".twoArg("Two paths", diffFiles _), - "copy-flat" copy flat + "exec".nonEmpty(execute), + "copy".copy(to => rebase(baseDirectory, to)), + "copy-file".twoArg("Two paths", copyFile), + "must-mirror".twoArg("Two paths", diffFiles), + "copy-flat".copy(flat), ) def apply(command: String, arguments: List[String]): Unit = diff --git a/internal/util-scripted/src/main/scala/sbt/internal/scripted/FilteredLoader.scala b/internal/util-scripted/src/main/scala/sbt/internal/scripted/FilteredLoader.scala index 2de59b5f7..65141672e 100644 --- a/internal/util-scripted/src/main/scala/sbt/internal/scripted/FilteredLoader.scala +++ b/internal/util-scripted/src/main/scala/sbt/internal/scripted/FilteredLoader.scala @@ -15,7 +15,7 @@ import java.net.URL final class FilteredLoader(parent: ClassLoader) extends ClassLoader(parent) { @throws(classOf[ClassNotFoundException]) - override final def loadClass(className: String, resolve: Boolean): Class[_] = { + override final def loadClass(className: String, resolve: Boolean): Class[?] = { if (className.startsWith("java.") || className.startsWith("javax.")) super.loadClass(className, resolve) else diff --git a/internal/util-scripted/src/main/scala/sbt/internal/scripted/ScriptedTests.scala b/internal/util-scripted/src/main/scala/sbt/internal/scripted/ScriptedTests.scala index 17e6b3200..b5b4a392a 100644 --- a/internal/util-scripted/src/main/scala/sbt/internal/scripted/ScriptedTests.scala +++ b/internal/util-scripted/src/main/scala/sbt/internal/scripted/ScriptedTests.scala @@ -144,7 +144,7 @@ final class ScriptedTests( // // val sbtHandler = new SbtHandler(testDirectory, launcher, buffered, launchOpts) // new TestScriptParser(Map('$' -> fileHandler, /* '>' -> sbtHandler, */ '#' -> CommentHandler)) val scriptConfig = new ScriptConfig(label, testDirectory, log) - new TestScriptParser(handlersProvider getHandlers scriptConfig) + new TestScriptParser(handlersProvider.getHandlers(scriptConfig)) } val (file, pending) = { val normal = new File(testDirectory, ScriptFilename) @@ -224,7 +224,7 @@ final class ListTests(baseDirectory: File, accept: ScriptedTest => Boolean, log: log.warn("Tests skipped in group " + group.getName + ":") skipped.foreach(testName => log.warn(" " + testName.getName)) } - Seq(included.map(_.getName): _*) + Seq(included.map(_.getName)*) } } } diff --git a/internal/util-scripted/src/main/scala/sbt/internal/scripted/TestScriptParser.scala b/internal/util-scripted/src/main/scala/sbt/internal/scripted/TestScriptParser.scala index 51309a78d..c1cf65b0e 100644 --- a/internal/util-scripted/src/main/scala/sbt/internal/scripted/TestScriptParser.scala +++ b/internal/util-scripted/src/main/scala/sbt/internal/scripted/TestScriptParser.scala @@ -109,7 +109,7 @@ class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParse ("\'" ~> "[^'\n\r]*".r <~ "\'") | "\"[^\"\n\r]*\"".r | WordRegex def startCharacterParser: Parser[Char] = - elem("start character", handlers.contains _) | + elem("start character", handlers.contains) | ( (newline | err("expected start character " + handlers.keys.mkString("(", "", ")"))) ~> failure("end of input") diff --git a/lm-core/src/main/scala/sbt/internal/librarymanagement/VersionRange.scala b/lm-core/src/main/scala/sbt/internal/librarymanagement/VersionRange.scala index f1579d65e..1d5112c64 100644 --- a/lm-core/src/main/scala/sbt/internal/librarymanagement/VersionRange.scala +++ b/lm-core/src/main/scala/sbt/internal/librarymanagement/VersionRange.scala @@ -6,11 +6,11 @@ object VersionRange { /** True if the revision is an ivy-range, not a complete revision. */ def isVersionRange(revision: String): Boolean = { - (revision endsWith "+") || - (revision contains "[") || - (revision contains "]") || - (revision contains "(") || - (revision contains ")") + (revision.endsWith("+")) || + (revision.contains("[")) || + (revision.contains("]")) || + (revision.contains("(")) || + (revision.contains(")")) } // Assuming Ivy is used to resolve conflict, this removes the version range @@ -58,7 +58,7 @@ object VersionRange { case NumPlusPattern(tail) => (0 until maxDigit).map(plusRange(tail, _)).mkString(",") case DotNumPlusPattern(base, tail) => (0 until maxDigit).map(plusRange(base + "." + tail, _)).mkString(",") - case rev if rev endsWith "+" => + case rev if rev.endsWith("+") => sys.error(s"dynamic revision '$rev' cannot be translated to POM") case rev if startSym(rev(0)) && stopSym(rev(rev.length - 1)) => val start = rev(0) diff --git a/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/GlobalLockFormat.scala b/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/GlobalLockFormat.scala index 2e4ced132..ce9f556af 100644 --- a/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/GlobalLockFormat.scala +++ b/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/GlobalLockFormat.scala @@ -15,7 +15,9 @@ trait GlobalLockFormat { self: BasicJsonProtocol => implicit lazy val globalLockIsoString: IsoString[GlobalLock] = IsoString.iso(_ => "", _ => NoGlobalLock) - implicit lazy val GlobalLockFormat: JsonFormat[GlobalLock] = isoStringFormat(globalLockIsoString) + implicit lazy val GlobalLockFormat: JsonFormat[GlobalLock] = isoStringFormat(using + globalLockIsoString + ) } private[sbt] object GlobalLockFormats { diff --git a/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/LoggerFormat.scala b/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/LoggerFormat.scala index f10fdb03f..2335589e1 100644 --- a/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/LoggerFormat.scala +++ b/lm-core/src/main/scala/sbt/internal/librarymanagement/formats/LoggerFormat.scala @@ -12,5 +12,5 @@ trait LoggerFormat { self: BasicJsonProtocol => implicit lazy val xsbtiLoggerIsoString: IsoString[Logger] = IsoString.iso(_ => "", _ => Null) - implicit lazy val LoggerFormat: JsonFormat[Logger] = isoStringFormat(implicitly) + implicit lazy val LoggerFormat: JsonFormat[Logger] = isoStringFormat(using implicitly) } diff --git a/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala b/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala index 27143a9a4..0a3ff2300 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala @@ -35,7 +35,7 @@ object Configurations { } private[sbt] def internal(base: Configuration, ext: Configuration*) = - Configuration.of(base.id + "Internal", base.name + "-internal").extend(ext: _*).hide + Configuration.of(base.id + "Internal", base.name + "-internal").extend(ext*).hide private[sbt] def fullInternal(base: Configuration): Configuration = internal(base, base, Optional, Provided) private[sbt] def optionalInternal(base: Configuration): Configuration = @@ -44,10 +44,10 @@ object Configurations { lazy val Default = Configuration.of("Default", "default") lazy val Compile = Configuration.of("Compile", "compile") @deprecated("Create a separate subproject for testing instead", "1.9.0") - lazy val IntegrationTest = Configuration.of("IntegrationTest", "it") extend (Runtime) + lazy val IntegrationTest = Configuration.of("IntegrationTest", "it").extend(Runtime) lazy val Provided = Configuration.of("Provided", "provided") - lazy val Runtime = Configuration.of("Runtime", "runtime") extend (Compile) - lazy val Test = Configuration.of("Test", "test") extend (Runtime) + lazy val Runtime = Configuration.of("Runtime", "runtime").extend(Compile) + lazy val Test = Configuration.of("Test", "test").extend(Runtime) lazy val System = Configuration.of("System", "system") lazy val Optional = Configuration.of("Optional", "optional") lazy val Pom = Configuration.of("Pom", "pom") @@ -66,9 +66,9 @@ object Configurations { private[sbt] def removeDuplicates(configs: Iterable[Configuration]) = Set( scala.collection.mutable - .Map(configs.map(config => (config.name, config)).toSeq: _*) + .Map(configs.map(config => (config.name, config)).toSeq*) .values - .toList: _* + .toList* ) /** Returns true if the configuration should be under the influence of scalaVersion. */ @@ -115,9 +115,9 @@ private[sbt] object ConfigurationMacro: import quotes.reflect.* def enclosingTerm(sym: Symbol): Symbol = sym match - case sym if sym.flags is Flags.Macro => enclosingTerm(sym.owner) - case sym if !sym.isTerm => enclosingTerm(sym.owner) - case _ => sym + case sym if sym.flags.is(Flags.Macro) => enclosingTerm(sym.owner) + case sym if !sym.isTerm => enclosingTerm(sym.owner) + case _ => sym val term = enclosingTerm(Symbol.spliceOwner) if !term.isValDef then report.error( diff --git a/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationFormats.scala b/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationFormats.scala index 66bea9aae..b498b8fc0 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationFormats.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/ConfigurationFormats.scala @@ -7,7 +7,7 @@ package librarymanagement import _root_.sjsonnew.{ deserializationError, Builder, JsonFormat, Unbuilder } trait ConfigurationFormats { - self: sbt.librarymanagement.ConfigurationFormats with sjsonnew.BasicJsonProtocol => + self: sbt.librarymanagement.ConfigurationFormats & sjsonnew.BasicJsonProtocol => implicit lazy val ConfigurationFormat: JsonFormat[sbt.librarymanagement.Configuration] = new JsonFormat[sbt.librarymanagement.Configuration] { override def read[J]( diff --git a/lm-core/src/main/scala/sbt/librarymanagement/CrossVersion.scala b/lm-core/src/main/scala/sbt/librarymanagement/CrossVersion.scala index 6928f7df9..71130476e 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/CrossVersion.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/CrossVersion.scala @@ -455,14 +455,10 @@ trait For2_13Use3Formats { self: sjsonnew.BasicJsonProtocol => } trait CrossVersionFormats { - self: sjsonnew.BasicJsonProtocol - with sbt.librarymanagement.DisabledFormats - with sbt.librarymanagement.BinaryFormats - with sbt.librarymanagement.ConstantFormats - with sbt.librarymanagement.PatchFormats - with sbt.librarymanagement.FullFormats - with sbt.librarymanagement.For3Use2_13Formats - with sbt.librarymanagement.For2_13Use3Formats => + self: sjsonnew.BasicJsonProtocol & sbt.librarymanagement.DisabledFormats & + sbt.librarymanagement.BinaryFormats & sbt.librarymanagement.ConstantFormats & + sbt.librarymanagement.PatchFormats & sbt.librarymanagement.FullFormats & + sbt.librarymanagement.For3Use2_13Formats & sbt.librarymanagement.For2_13Use3Formats => implicit lazy val CrossVersionFormat: JsonFormat[CrossVersion] = { val format = flatUnionFormat8[ CrossVersion, diff --git a/lm-core/src/main/scala/sbt/librarymanagement/DependencyBuilders.scala b/lm-core/src/main/scala/sbt/librarymanagement/DependencyBuilders.scala index 99e64106d..77d9ff22f 100755 --- a/lm-core/src/main/scala/sbt/librarymanagement/DependencyBuilders.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/DependencyBuilders.scala @@ -67,7 +67,7 @@ object DependencyBuilders { } final class RepositoryName private[sbt] (name: String) { - def at(location: String): MavenRepository = { + infix def at(location: String): MavenRepository = { nonEmpty(location, "Repository location") MavenRepository(name, location) } diff --git a/lm-core/src/main/scala/sbt/librarymanagement/DependencyFilter.scala b/lm-core/src/main/scala/sbt/librarymanagement/DependencyFilter.scala index 25ca6eddc..7d6ae20e9 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/DependencyFilter.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/DependencyFilter.scala @@ -68,7 +68,7 @@ object DependencyFilter extends DependencyFilterExtra { } implicit def fnToConfigurationFilter(f: ConfigRef => Boolean): ConfigurationFilter = new ConfigurationFilter { def apply(c: ConfigRef) = f(c) } - implicit def subDepFilterToFn[Arg](f: SubDepFilter[Arg, _]): Arg => Boolean = f apply _ + implicit def subDepFilterToFn[Arg](f: SubDepFilter[Arg, ?]): Arg => Boolean = f.apply(_) } trait DependencyFilter { def apply(configuration: ConfigRef, module: ModuleID, artifact: Artifact): Boolean diff --git a/lm-core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala b/lm-core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala index 8a0ccd996..19e5718d4 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala @@ -169,7 +169,7 @@ class DependencyResolution private[sbt] (lmEngine: DependencyResolutionInterface restrictedCopy(m, true) } // Adding list of explicit artifacts here. - val exls = Map(config.excludes map { case (k, v) => (k, v.toSet) }: _*) + val exls = Map(config.excludes map { case (k, v) => (k, v.toSet) }*) val deps = baseModules.distinct flatMap classifiedArtifacts(classifiers, exls, artifacts) val base = restrictedCopy(id, true).withName(id.name + classifiers.mkString("$", "_", "")) val moduleSetting = ModuleDescriptorConfiguration(base, ModuleInfo(base.name)) diff --git a/lm-core/src/main/scala/sbt/librarymanagement/EvictionError.scala b/lm-core/src/main/scala/sbt/librarymanagement/EvictionError.scala index da0e03033..b1ce20ee3 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/EvictionError.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/EvictionError.scala @@ -81,7 +81,7 @@ object EvictionError { case _ => List((s.organization, s.name) -> versionScheme) } - }: _*) + }*) pairs foreach { // don't report on a transitive eviction that does not have a winner diff --git a/lm-core/src/main/scala/sbt/librarymanagement/ResolverExtra.scala b/lm-core/src/main/scala/sbt/librarymanagement/ResolverExtra.scala index ebe241976..a8a6101a2 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/ResolverExtra.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/ResolverExtra.scala @@ -36,7 +36,7 @@ private[librarymanagement] abstract class MavenRepositoryFunctions { private[librarymanagement] abstract class PatternsFunctions { implicit def defaultPatterns: Patterns = Resolver.defaultPatterns - def apply(artifactPatterns: String*): Patterns = Patterns(true, artifactPatterns: _*) + def apply(artifactPatterns: String*): Patterns = Patterns(true, artifactPatterns*) def apply(isMavenCompatible: Boolean, artifactPatterns: String*): Patterns = { val patterns = artifactPatterns.toVector Patterns() @@ -54,7 +54,7 @@ private[librarymanagement] trait SshBasedRepositoryExtra { type RepositoryType <: SshBasedRepository protected def copy(connection: SshConnection): RepositoryType private def copy(authentication: SshAuthentication): RepositoryType = - copy(connection withAuthentication authentication) + copy(connection.withAuthentication(authentication)) /** Configures this to use the specified user name and password when connecting to the remote repository. */ def as(user: String, password: String): RepositoryType = as(user, Some(password)) diff --git a/lm-core/src/main/scala/sbt/librarymanagement/UnresolvedWarning.scala b/lm-core/src/main/scala/sbt/librarymanagement/UnresolvedWarning.scala index 6f4aa832d..88a36918e 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/UnresolvedWarning.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/UnresolvedWarning.scala @@ -15,7 +15,7 @@ final class ResolveException( failed, Map(failed map { m => m -> Nil - }: _*) + }*) ) } @@ -36,7 +36,7 @@ object UnresolvedWarning { def modulePosition(m0: ModuleID): Option[SourcePosition] = config.modulePositions.find { case (m, _) => (m.organization == m0.organization) && - (m0.name startsWith m.name) && + (m0.name.startsWith(m.name)) && (m.revision == m0.revision) } map { case (_, p) => p diff --git a/lm-core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala b/lm-core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala index 958721689..0b2265c0c 100644 --- a/lm-core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala +++ b/lm-core/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala @@ -158,7 +158,7 @@ private[librarymanagement] abstract class UpdateReportExtra { } def retrieve(f: (ConfigRef, ModuleID, Artifact, File) => File): UpdateReport = - UpdateReport(cachedDescriptor, configurations map { _ retrieve f }, stats, stamps) + UpdateReport(cachedDescriptor, configurations.map { _.retrieve(f) }, stats, stamps) /** Gets the report for the given configuration, or `None` if the configuration was not resolved. */ def configuration(s: ConfigRef) = configurations.find(_.configuration == s) diff --git a/lm-core/src/test/scala/UpdateReportSpec.scala b/lm-core/src/test/scala/UpdateReportSpec.scala index d12d76585..0547e8613 100644 --- a/lm-core/src/test/scala/UpdateReportSpec.scala +++ b/lm-core/src/test/scala/UpdateReportSpec.scala @@ -36,16 +36,16 @@ class UpdateReportSpec extends AnyFlatSpec with Matchers { lazy val moduleReport = ( ModuleReport(ModuleID("org", "name", "1.0"), Vector.empty, Vector.empty) - withPublicationDate Some(epochCalendar) + .withPublicationDate(Some(epochCalendar)) ) lazy val organizationArtifactReport = OrganizationArtifactReport("org", "name", Vector(moduleReport)) val epochCalendar: java.util.Calendar = { - val utc = java.util.TimeZone getTimeZone "UTC" + val utc = java.util.TimeZone.getTimeZone("UTC") val c = new java.util.GregorianCalendar(utc, java.util.Locale.ENGLISH) - c setTimeInMillis 0L + c.setTimeInMillis(0L) c } } diff --git a/lm-core/src/test/scala/sbt/librarymanagement/VersionNumberSpec.scala b/lm-core/src/test/scala/sbt/librarymanagement/VersionNumberSpec.scala index 557d1f998..e98da9ea1 100644 --- a/lm-core/src/test/scala/sbt/librarymanagement/VersionNumberSpec.scala +++ b/lm-core/src/test/scala/sbt/librarymanagement/VersionNumberSpec.scala @@ -211,7 +211,7 @@ class VersionNumberSpec extends AnyFreeSpec with Matchers with Inside { case SemVer => "SemVer" case PackVer => "PackVer" case EarlySemVer => "EarlySemVer" - case _ => val s = vnc.name; if (s contains " ") s""""$s"""" else s + case _ => val s = vnc.name; if s.contains(" ") then s""""$s"""" else s } s"$prefix be $compatibilityStrategy compatible with $v2" in { vnc.isCompatible(VersionNumber(v1.value), VersionNumber(v2)) shouldBe expectOutcome diff --git a/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionRun.scala b/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionRun.scala index d7ee089e4..233c8e505 100644 --- a/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionRun.scala +++ b/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionRun.scala @@ -104,7 +104,7 @@ object ResolutionRun { params.params .addForceVersion( (if (isSandboxConfig) Nil - else params.interProjectDependencies.map(_.moduleVersion)): _* + else params.interProjectDependencies.map(_.moduleVersion))* ) .withForceScalaVersion(params.autoScalaLibOpt.nonEmpty) .withScalaVersionOpt(params.autoScalaLibOpt.map(_._2)) diff --git a/lm-coursier/src/main/scala/lmcoursier/internal/Resolvers.scala b/lm-coursier/src/main/scala/lmcoursier/internal/Resolvers.scala index 56fba5b77..10695e794 100644 --- a/lm-coursier/src/main/scala/lmcoursier/internal/Resolvers.scala +++ b/lm-coursier/src/main/scala/lmcoursier/internal/Resolvers.scala @@ -133,7 +133,7 @@ object Resolvers { private object IBiblioRepository { - private def stringVector(v: java.util.List[_]): Vector[String] = + private def stringVector(v: java.util.List[?]): Vector[String] = Option(v).map(_.asScala.toVector).getOrElse(Vector.empty).collect { case s: String => s } diff --git a/lm-coursier/src/main/scala/lmcoursier/internal/UpdateRun.scala b/lm-coursier/src/main/scala/lmcoursier/internal/UpdateRun.scala index 13e7d77d5..5b654bc1f 100644 --- a/lm-coursier/src/main/scala/lmcoursier/internal/UpdateRun.scala +++ b/lm-coursier/src/main/scala/lmcoursier/internal/UpdateRun.scala @@ -44,7 +44,7 @@ object UpdateRun { } .groupBy(_.withConfiguration(Configuration.empty)) .map { case (dep, l) => - dep.withConfiguration(Configuration.join(l.map(_.configuration).toSeq: _*)) + dep.withConfiguration(Configuration.join(l.map(_.configuration).toSeq*)) } .toSet diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ConvertResolver.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ConvertResolver.scala index 3b9b7b196..64d5c9922 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ConvertResolver.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ConvertResolver.scala @@ -51,7 +51,7 @@ private[sbt] object ConvertResolver { */ private object ChecksumFriendlyURLResolver { import java.lang.reflect.AccessibleObject - private def reflectiveLookup[A <: AccessibleObject](f: Class[_] => A): Option[A] = + private def reflectiveLookup[A <: AccessibleObject](f: Class[?] => A): Option[A] = try { val cls = classOf[RepositoryResolver] val thing = f(cls) @@ -377,8 +377,8 @@ private[sbt] object ConvertResolver { else BasicResolver.DESCRIPTOR_REQUIRED ) resolver.setCheckconsistency(!patterns.skipConsistencyCheck) - patterns.ivyPatterns.foreach(p => resolver.addIvyPattern(settings substitute p)) - patterns.artifactPatterns.foreach(p => resolver.addArtifactPattern(settings substitute p)) + patterns.ivyPatterns.foreach(p => resolver.addIvyPattern(settings.substitute(p))) + patterns.artifactPatterns.foreach(p => resolver.addArtifactPattern(settings.substitute(p))) } /** @@ -452,7 +452,7 @@ private[sbt] object ConvertResolver { catch { case e: java.io.IOException if e.getMessage.contains("destination already exists") => val overwriteWarning = - if (destination contains "-SNAPSHOT") s"Attempting to overwrite $destination" + if destination.contains("-SNAPSHOT") then s"Attempting to overwrite $destination" else s"Attempting to overwrite $destination (non-SNAPSHOT)\n\tYou need to remove it from the cache manually to take effect." import org.apache.ivy.util.Message diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/CustomPomParser.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/CustomPomParser.scala index 655d57d61..05dfe690e 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/CustomPomParser.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/CustomPomParser.scala @@ -121,7 +121,7 @@ object CustomPomParser { } private def hash(ss: Seq[String]): String = - Hash.toHex(Hash(ss.flatMap(_ getBytes "UTF-8").toArray)) + Hash.toHex(Hash(ss.flatMap(_.getBytes("UTF-8")).toArray)) // Unfortunately, ModuleDescriptorParserRegistry is add-only and is a singleton instance. lazy val registerDefault: Unit = ModuleDescriptorParserRegistry.getInstance.addParser(default) @@ -136,12 +136,11 @@ object CustomPomParser { val MyHash = MakeTransformHash(md) // sbt 0.13.1 used "sbtTransformHash" instead of "e:sbtTransformHash" until #1192 so read both Option(extraInfo).isDefined && - ((Option(extraInfo get TransformedHashKey) orElse Option( - extraInfo get oldTransformedHashKey - )) match { + (Option(extraInfo.get(TransformedHashKey)) + .orElse(Option(extraInfo.get(oldTransformedHashKey))) match case Some(MyHash) => true case _ => false - }) + ) } private def defaultTransformImpl( diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/FakeResolver.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/FakeResolver.scala index 00c0275ae..fc2dd2463 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/FakeResolver.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/FakeResolver.scala @@ -113,7 +113,7 @@ private[sbt] class FakeResolver(private var name: String, cacheDir: File, module val mrid = dd.getDependencyRevisionId() val artifact = modules get ((organisation, name, revision)) map { arts => - val artifacts: Array[DependencyArtifactDescriptor] = arts.toArray map (_ artifactOf dd) + val artifacts: Array[DependencyArtifactDescriptor] = arts.toArray.map(_.artifactOf(dd)) val moduleDescriptor = DefaultModuleDescriptor.newDefaultInstance(mrid, artifacts) val defaultArtifact = arts.headOption match { case Some(FakeArtifact(name, tpe, ext, _)) => @@ -163,13 +163,13 @@ private[sbt] class FakeResolver(private var name: String, cacheDir: File, module override def listTokenValues( tokens: Array[String], - criteria: java.util.Map[_, _] - ): Array[java.util.Map[_, _]] = + criteria: java.util.Map[?, ?] + ): Array[java.util.Map[?, ?]] = Array.empty override def listTokenValues( token: String, - otherTokenValues: java.util.Map[_, _] + otherTokenValues: java.util.Map[?, ?] ): Array[String] = Array.empty diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/Ivy.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/Ivy.scala index 96c1cd39d..4721604cd 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/Ivy.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/Ivy.scala @@ -515,9 +515,9 @@ private[sbt] object IvySbt { private[sbt] def isChanging(dd: DependencyDescriptor): Boolean = dd.isChanging || isChanging(dd.getDependencyRevisionId) private[sbt] def isChanging(module: ModuleID): Boolean = - module.revision endsWith "-SNAPSHOT" + module.revision.endsWith("-SNAPSHOT") private[sbt] def isChanging(mrid: ModuleRevisionId): Boolean = - mrid.getRevision endsWith "-SNAPSHOT" + mrid.getRevision.endsWith("-SNAPSHOT") def resolverChain( name: String, @@ -564,7 +564,7 @@ private[sbt] object IvySbt { def hasImplicitClassifier(artifact: IArtifact): Boolean = { import scala.jdk.CollectionConverters._ artifact.getQualifiedExtraAttributes.asScala.keys - .exists(_.asInstanceOf[String] startsWith "m:") + .exists(_.asInstanceOf[String].startsWith("m:")) } private def setModuleConfigurations( settings: IvySettings, @@ -956,17 +956,16 @@ private[sbt] object IvySbt { val deps = new java.util.LinkedHashMap[ModuleRevisionId, List[DependencyDescriptor]] for (dd <- dependencies) { val id = dd.getDependencyRevisionId - val updated = deps get id match { + val updated = deps.get(id) match case null => dd :: Nil case v => dd :: v - } deps.put(id, updated) } import scala.jdk.CollectionConverters._ deps.values.asScala.toSeq.flatMap { dds => - val mergeable = dds.lazyZip(dds.tail).forall(ivyint.MergeDescriptors.mergeable _) - if (mergeable) dds.reverse.reduceLeft(ivyint.MergeDescriptors.apply _) :: Nil else dds + val mergeable = dds.lazyZip(dds.tail).forall(ivyint.MergeDescriptors.mergeable) + if (mergeable) dds.reverse.reduceLeft(ivyint.MergeDescriptors.apply) :: Nil else dds } } diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala index 844cec590..d6069dd20 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala @@ -127,7 +127,7 @@ object IvyActions { Option(deliver(module, configuration, log)) } - val artifacts = Map(configuration.artifacts: _*) + val artifacts = Map(configuration.artifacts*) val checksums = configuration.checksums module.withModule(log) { case (ivy, md, _) => val resolver = ivy.getSettings.getResolver(resolverName) diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala index 836b3ede7..578fec0a3 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala @@ -82,14 +82,14 @@ object IvyRetrieve { confReport: ConfigurationResolveReport, dep: IvyNode ): ModuleReport = { - def toExtraAttributes(ea: ju.Map[_, _]): Map[String, String] = + def toExtraAttributes(ea: ju.Map[?, ?]): Map[String, String] = Map(ea.entrySet.toArray collect { case entry: ju.Map.Entry[_, _] if nonEmptyString(entry.getKey.toString).isDefined && nonEmptyString( entry.getValue.toString ).isDefined => (entry.getKey.toString, entry.getValue.toString) - }: _*) + }*) def toCaller(caller: IvyCaller): Caller = { val m = toModuleID(caller.getModuleRevisionId) val callerConfigurations = caller.getCallerConfigurations.toVector collect { diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyScalaUtil.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyScalaUtil.scala index 86daf8bb6..9353222cd 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyScalaUtil.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/IvyScalaUtil.scala @@ -186,7 +186,7 @@ object IvyScalaUtil { if (configurations.isEmpty) names else { val configSet = configurationSet(configurations) - configSet.intersect(HashSet(names: _*)) + configSet.intersect(HashSet(names*)) configSet.toArray } } diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/MakePom.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/MakePom.scala index 58d05628e..aed855d3b 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/MakePom.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/MakePom.scala @@ -503,7 +503,7 @@ class MakePom(val log: Logger) { r match { case c: ChainResolver => flatten(castResolvers(c.getResolvers)); case _ => r :: Nil } // cast the contents of a pre-generics collection - private def castResolvers(s: java.util.Collection[_]): Seq[DependencyResolver] = { + private def castResolvers(s: java.util.Collection[?]): Seq[DependencyResolver] = { import scala.jdk.CollectionConverters._ s.asScala.toSeq.map(_.asInstanceOf[DependencyResolver]) } @@ -531,7 +531,7 @@ class MakePom(val log: Logger) { configurations: Option[Iterable[Configuration]] ): Seq[DependencyDescriptor] = { val keepConfigurations = IvySbt.getConfigurations(module, configurations) - val keepSet: Set[String] = Set(keepConfigurations.toSeq: _*) + val keepSet: Set[String] = Set(keepConfigurations.toSeq*) def translate(dependency: DependencyDescriptor) = { val keep = dependency.getModuleConfigurations .filter((conf: String) => keepSet.contains(conf)) diff --git a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala index ed0a8a6b1..c3b414ef5 100644 --- a/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala +++ b/lm-ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala @@ -285,7 +285,7 @@ private[sbt] class CachedResolutionResolveCache { ): (Vector[ModuleReport], Vector[ModuleReport]) = { val moduleIdMap = Map(conflicts map { x => x.module -> x - }: _*) + }*) ( surviving map moduleIdMap, evicted map moduleIdMap map { @@ -412,7 +412,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { } log.debug("- Unresolved path " + path.toString) m -> path - }: _*) + }*) val failed = failedPaths.keys.toSeq Left(new ResolveException(messages, failed, failedPaths)) } @@ -507,7 +507,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { ) } } - new ResolveException(messages, failed, ListMap(failedPaths: _*)) + new ResolveException(messages, failed, ListMap(failedPaths*)) } def mergeReports( @@ -589,7 +589,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { oar.organization == organization && oar.name == name } ((organization, name), xs) - }: _*) + }*) // this returns a List of Lists of (org, name). should be deterministic def detectLoops( allModules: Map[(String, String), Vector[OrganizationArtifactReport]] @@ -625,7 +625,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { loopLists.toList } val allModules2: mutable.Map[(String, String), Vector[OrganizationArtifactReport]] = - mutable.Map(allModules0.toSeq: _*) + mutable.Map(allModules0.toSeq*) @tailrec def breakLoops(loops: List[List[(String, String)]]): Unit = loops match { case Nil => () @@ -836,7 +836,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { } Seq(((organization, name), oars)) } - Map(reports: _*) + Map(reports*) } /** @@ -988,7 +988,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { node.getRealConfs(conf).toVector } conf0.getName -> remapped - }: _*) + }*) // This emulates test-internal extending test configuration etc. val remappedConfigs: Map[String, Vector[String]] = rootModuleConfs.foldLeft(remappedConfigs0) { (acc0, c) => diff --git a/lm-ivy/src/main/scala/sbt/librarymanagement/ivy/formats/UpdateOptionsFormat.scala b/lm-ivy/src/main/scala/sbt/librarymanagement/ivy/formats/UpdateOptionsFormat.scala index 6929546be..94bdc2138 100644 --- a/lm-ivy/src/main/scala/sbt/librarymanagement/ivy/formats/UpdateOptionsFormat.scala +++ b/lm-ivy/src/main/scala/sbt/librarymanagement/ivy/formats/UpdateOptionsFormat.scala @@ -5,34 +5,21 @@ import sjsonnew._ import sbt.librarymanagement._ trait UpdateOptionsFormat { - self: BasicJsonProtocol - with ModuleIDFormats - with ResolverFormats - with sbt.librarymanagement.ArtifactFormats - with sbt.librarymanagement.ConfigRefFormats - with sbt.librarymanagement.ChecksumFormats - with sbt.librarymanagement.InclExclRuleFormats - with sbt.librarymanagement.CrossVersionFormats - with sbt.librarymanagement.DisabledFormats - with sbt.librarymanagement.BinaryFormats - with sbt.librarymanagement.ConstantFormats - with sbt.librarymanagement.PatchFormats - with sbt.librarymanagement.FullFormats - with sbt.librarymanagement.For3Use2_13Formats - with sbt.librarymanagement.For2_13Use3Formats - with sbt.librarymanagement.ChainedResolverFormats - with sbt.librarymanagement.MavenRepoFormats - with sbt.librarymanagement.MavenCacheFormats - with sbt.librarymanagement.PatternsFormats - with sbt.librarymanagement.FileConfigurationFormats - with sbt.librarymanagement.FileRepositoryFormats - with sbt.librarymanagement.URLRepositoryFormats - with sbt.librarymanagement.SshConnectionFormats - with sbt.librarymanagement.SshAuthenticationFormats - with sbt.librarymanagement.SshRepositoryFormats - with sbt.librarymanagement.SftpRepositoryFormats - with sbt.librarymanagement.PasswordAuthenticationFormats - with sbt.librarymanagement.KeyFileAuthenticationFormats => + self: BasicJsonProtocol & ModuleIDFormats & ResolverFormats & + sbt.librarymanagement.ArtifactFormats & sbt.librarymanagement.ConfigRefFormats & + sbt.librarymanagement.ChecksumFormats & sbt.librarymanagement.InclExclRuleFormats & + sbt.librarymanagement.CrossVersionFormats & sbt.librarymanagement.DisabledFormats & + sbt.librarymanagement.BinaryFormats & sbt.librarymanagement.ConstantFormats & + sbt.librarymanagement.PatchFormats & sbt.librarymanagement.FullFormats & + sbt.librarymanagement.For3Use2_13Formats & sbt.librarymanagement.For2_13Use3Formats & + sbt.librarymanagement.ChainedResolverFormats & sbt.librarymanagement.MavenRepoFormats & + sbt.librarymanagement.MavenCacheFormats & sbt.librarymanagement.PatternsFormats & + sbt.librarymanagement.FileConfigurationFormats & sbt.librarymanagement.FileRepositoryFormats & + sbt.librarymanagement.URLRepositoryFormats & sbt.librarymanagement.SshConnectionFormats & + sbt.librarymanagement.SshAuthenticationFormats & sbt.librarymanagement.SshRepositoryFormats & + sbt.librarymanagement.SftpRepositoryFormats & + sbt.librarymanagement.PasswordAuthenticationFormats & + sbt.librarymanagement.KeyFileAuthenticationFormats => /* This is necessary to serialize/deserialize `directResolvers`. */ private implicit val moduleIdJsonKeyFormat: sjsonnew.JsonKeyFormat[ModuleID] = { new sjsonnew.JsonKeyFormat[ModuleID] { diff --git a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionErrorSpec.scala b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionErrorSpec.scala index 2dd357978..1cb41c0c9 100644 --- a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionErrorSpec.scala +++ b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionErrorSpec.scala @@ -119,17 +119,23 @@ object EvictionErrorSpec extends BaseIvySpecification { def oldAkkaPvp = List("com.typesafe.akka" % "*" % "pvp") lazy val `akkaActor2.1.4` = - ModuleID("com.typesafe.akka", "akka-actor", "2.1.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.1.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) lazy val `akkaActor2.3.0` = - ModuleID("com.typesafe.akka", "akka-actor", "2.3.0").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.3.0") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) lazy val `akkaActor2.6.0` = - ModuleID("com.typesafe.akka", "akka-actor", "2.6.0").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.6.0") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) lazy val `scala2.10.4` = ModuleID("org.scala-lang", "scala-library", "2.10.4").withConfigurations(Some("compile")) lazy val `scala2.12.17` = @@ -137,13 +143,17 @@ object EvictionErrorSpec extends BaseIvySpecification { lazy val `scala2.13.3` = ModuleID("org.scala-lang", "scala-library", "2.13.3").withConfigurations(Some("compile")) lazy val `bananaSesame0.4` = - ModuleID("org.w3", "banana-sesame", "0.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary // uses akka-actor 2.1.4 + ModuleID("org.w3", "banana-sesame", "0.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) // uses akka-actor 2.1.4 lazy val `akkaRemote2.3.4` = - ModuleID("com.typesafe.akka", "akka-remote", "2.3.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary // uses akka-actor 2.3.4 + ModuleID("com.typesafe.akka", "akka-remote", "2.3.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) // uses akka-actor 2.3.4 lazy val `http4s0.21.11` = ("org.http4s" %% "http4s-blaze-server" % "0.21.11").withConfigurations(Some("compile")) // https://repo1.maven.org/maven2/org/typelevel/cats-effect_2.13/3.0.0-M4/cats-effect_2.13-3.0.0-M4.pom diff --git a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionWarningSpec.scala b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionWarningSpec.scala index 0dedc0d14..62777627b 100644 --- a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionWarningSpec.scala +++ b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/EvictionWarningSpec.scala @@ -311,17 +311,23 @@ object EvictionWarningSpec extends BaseIvySpecification { } def akkaActor214 = - ModuleID("com.typesafe.akka", "akka-actor", "2.1.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.1.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) def akkaActor230 = - ModuleID("com.typesafe.akka", "akka-actor", "2.3.0").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.3.0") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) def akkaActor234 = - ModuleID("com.typesafe.akka", "akka-actor", "2.3.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.3.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) def scala2102 = ModuleID("org.scala-lang", "scala-library", "2.10.2").withConfigurations(Some("compile")) def scala2103 = @@ -336,17 +342,23 @@ object EvictionWarningSpec extends BaseIvySpecification { Some("compile") ) // uses commons-io 2.4 def unfilteredUploads080 = - ModuleID("net.databinder", "unfiltered-uploads", "0.8.0").withConfigurations( - Some("compile") - ) cross CrossVersion.binary // uses commons-io 1.4 + ModuleID("net.databinder", "unfiltered-uploads", "0.8.0") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) // uses commons-io 1.4 def bananaSesame04 = - ModuleID("org.w3", "banana-sesame", "0.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary // uses akka-actor 2.1.4 + ModuleID("org.w3", "banana-sesame", "0.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) // uses akka-actor 2.1.4 def akkaRemote234 = - ModuleID("com.typesafe.akka", "akka-remote", "2.3.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary // uses akka-actor 2.3.4 + ModuleID("com.typesafe.akka", "akka-remote", "2.3.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) // uses akka-actor 2.3.4 def fullOptions = EvictionWarningOptions.full def javaLibDirectDeps = Vector(commonsIo14, commonsIo24) diff --git a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/InconsistentDuplicateSpec.scala b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/InconsistentDuplicateSpec.scala index 46e830c04..a4465e58b 100644 --- a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/InconsistentDuplicateSpec.scala +++ b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/InconsistentDuplicateSpec.scala @@ -24,15 +24,21 @@ object InconsistentDuplicateSpec extends BasicTestSuite { } def akkaActor214 = - ModuleID("com.typesafe.akka", "akka-actor", "2.1.4").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.1.4") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) def akkaActor230 = - ModuleID("com.typesafe.akka", "akka-actor", "2.3.0").withConfigurations( - Some("compile") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.3.0") + .withConfigurations( + Some("compile") + ) + .cross(CrossVersion.binary) def akkaActor230Test = - ModuleID("com.typesafe.akka", "akka-actor", "2.3.0").withConfigurations( - Some("test") - ) cross CrossVersion.binary + ModuleID("com.typesafe.akka", "akka-actor", "2.3.0") + .withConfigurations( + Some("test") + ) + .cross(CrossVersion.binary) } diff --git a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/PlatformResolutionSpec.scala b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/PlatformResolutionSpec.scala index f6ce21736..3e8e8d496 100644 --- a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/PlatformResolutionSpec.scala +++ b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/PlatformResolutionSpec.scala @@ -10,8 +10,10 @@ object PlatformResolutionSpec extends BaseIvySpecification { cleanCache() val m = exampleAutoModule(platform = None) assert( - update(m).configurations.head.modules.map(_.toString).mkString - contains "com.github.scopt:scopt_2.13:4.1.0" + update(m).configurations.head.modules + .map(_.toString) + .mkString + .contains("com.github.scopt:scopt_2.13:4.1.0") ) } @@ -19,8 +21,10 @@ object PlatformResolutionSpec extends BaseIvySpecification { cleanCache() val m = exampleAutoModule(platform = Some("sjs1")) assert( - update(m).configurations.head.modules.map(_.toString).mkString - contains "com.github.scopt:scopt_sjs1_2.13" + update(m).configurations.head.modules + .map(_.toString) + .mkString + .contains("com.github.scopt:scopt_sjs1_2.13") ) } @@ -33,8 +37,10 @@ object PlatformResolutionSpec extends BaseIvySpecification { platform = Some(sjs1), ) assert( - update(m).configurations.head.modules.map(_.toString).mkString - contains "junit:junit:4.13.1" + update(m).configurations.head.modules + .map(_.toString) + .mkString + .contains("junit:junit:4.13.1") ) } @@ -47,8 +53,10 @@ object PlatformResolutionSpec extends BaseIvySpecification { platform = None, ) assert( - update(m).configurations.head.modules.map(_.toString).mkString - contains "com.github.scopt:scopt_sjs1_2.13" + update(m).configurations.head.modules + .map(_.toString) + .mkString + .contains("com.github.scopt:scopt_sjs1_2.13") ) } @@ -61,8 +69,10 @@ object PlatformResolutionSpec extends BaseIvySpecification { platform = None, ) assert( - update(m).configurations.head.modules.map(_.toString).mkString - contains "com.github.scopt:scopt_2.13:4.1.0" + update(m).configurations.head.modules + .map(_.toString) + .mkString + .contains("com.github.scopt:scopt_2.13:4.1.0") ) } diff --git a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/ResolutionSpec.scala b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/ResolutionSpec.scala index d85b4163a..e63abe26d 100644 --- a/lm-ivy/src/test/scala/sbt/internal/librarymanagement/ResolutionSpec.scala +++ b/lm-ivy/src/test/scala/sbt/internal/librarymanagement/ResolutionSpec.scala @@ -71,10 +71,10 @@ abstract class ResolutionSpec extends AbstractEngineSpec { val report = update(m) val modules: Seq[String] = report.configurations.head.modules map { _.toString } assert(modules exists { (x: String) => - x contains """org.jboss.netty:netty:3.2.0.Final""" + x.contains("""org.jboss.netty:netty:3.2.0.Final""") }) assert(!(modules exists { (x: String) => - x contains """org.jboss.netty:netty:3.2.1.Final""" + x.contains("""org.jboss.netty:netty:3.2.1.Final""") })) } diff --git a/main-actions/src/main/scala/sbt/ForkTests.scala b/main-actions/src/main/scala/sbt/ForkTests.scala index ca804ee9f..1aefe1e5e 100755 --- a/main-actions/src/main/scala/sbt/ForkTests.scala +++ b/main-actions/src/main/scala/sbt/ForkTests.scala @@ -43,9 +43,9 @@ private[sbt] object ForkTests { constant(TestOutput(TestResult.Passed, Map.empty[String, SuiteResult], Iterable.empty)) else mainTestTask(runners, opts, classpath, converter, fork, log, config.parallel).tagw( - config.tags: _* + config.tags* ) - main.tagw(tags: _*).dependsOn(all(opts.setup): _*) flatMap { results => + main.tagw(tags*).dependsOn(all(opts.setup)*) flatMap { results => all(opts.cleanup).join.map(_ => results) } } @@ -61,7 +61,7 @@ private[sbt] object ForkTests { tags: (Tag, Int)* ): Task[TestOutput] = { val opts = processOptions(config, tests, log) - apply(runners, opts, config, classpath, converter, fork, log, tags: _*) + apply(runners, opts, config, classpath, converter, fork, log, tags*) } def apply( @@ -191,7 +191,7 @@ private[sbt] object ForkTests { } } - private def forkFingerprint(f: Fingerprint): Fingerprint with Serializable = + private def forkFingerprint(f: Fingerprint): Fingerprint & Serializable = f match { case s: SubclassFingerprint => new ForkMain.SubclassFingerscan(s) case a: AnnotatedFingerprint => new ForkMain.AnnotatedFingerscan(a) @@ -222,9 +222,9 @@ private final class React( log.trace(t); react() case Array(group: String, tEvents: Array[Event]) => val events = tEvents.toSeq - listeners.foreach(_ startGroup group) + listeners.foreach(_.startGroup(group)) val event = TestEvent(events) - listeners.foreach(_ testEvent event) + listeners.foreach(_.testEvent(event)) val suiteResult = SuiteResult(events) results += group -> suiteResult listeners.foreach(_.endGroup(group, suiteResult.result)) diff --git a/main-actions/src/main/scala/sbt/Pkg.scala b/main-actions/src/main/scala/sbt/Pkg.scala index 96564b8e4..8b6a5c0f5 100644 --- a/main-actions/src/main/scala/sbt/Pkg.scala +++ b/main-actions/src/main/scala/sbt/Pkg.scala @@ -40,10 +40,10 @@ object Pkg: def JarManifest(m: Manifest) = PackageOption.JarManifest(m) def MainClass(mainClassName: String) = PackageOption.MainClass(mainClassName) def MainfestAttributes(attributes: (Attributes.Name, String)*) = - PackageOption.ManifestAttributes(attributes: _*) + PackageOption.ManifestAttributes(attributes*) def ManifestAttributes(attributes: (String, String)*) = { val converted = for ((name, value) <- attributes) yield (new Attributes.Name(name), value) - PackageOption.ManifestAttributes(converted: _*) + PackageOption.ManifestAttributes(converted*) } // 2010-01-01 private val default2010Timestamp: Long = 1262304000000L @@ -191,7 +191,7 @@ object Pkg: import Attributes.Name._ val attribKeys = Seq(SPECIFICATION_TITLE, SPECIFICATION_VERSION, SPECIFICATION_VENDOR) val attribVals = Seq(name, version, orgName) - PackageOption.ManifestAttributes(attribKeys.zip(attribVals): _*) + PackageOption.ManifestAttributes(attribKeys.zip(attribVals)*) } def addImplManifestAttributes( name: String, @@ -216,7 +216,7 @@ object Pkg: val attribVals = Seq(name, version, orgName, org) PackageOption.ManifestAttributes(attribKeys.zip(attribVals) ++ { homepage map (h => (IMPLEMENTATION_URL, h.toString)) - }: _*) + }*) } def makeJar( @@ -243,7 +243,7 @@ object Pkg: given manifestFormat: JsonFormat[Manifest] = projectFormat[Manifest, Array[Byte]]( m => { val bos = new java.io.ByteArrayOutputStream() - m write bos + m.write(bos) bos.toByteArray }, bs => new Manifest(new java.io.ByteArrayInputStream(bs)) @@ -308,7 +308,7 @@ object PackageOption: unbuilder.endObject() PackageOption.ManifestAttributes(attributes.map { case (k, v) => Attributes.Name(k) -> v - }: _*) + }*) case None => deserializationError("Expected JsObject but found None") override def write[J](obj: PackageOption.ManifestAttributes, builder: Builder[J]): Unit = builder.beginObject() diff --git a/main-actions/src/main/scala/sbt/RawCompileLike.scala b/main-actions/src/main/scala/sbt/RawCompileLike.scala index 2282dd5fa..16bec5ded 100644 --- a/main-actions/src/main/scala/sbt/RawCompileLike.scala +++ b/main-actions/src/main/scala/sbt/RawCompileLike.scala @@ -63,8 +63,8 @@ object RawCompileLike { options, maxErrors ) - val cachedComp = inputChanged(cacheStoreFactory make "inputs") { (inChanged, in: Inputs) => - inputChanged(cacheStoreFactory make "output") { + val cachedComp = inputChanged(cacheStoreFactory.make("inputs")) { (inChanged, in: Inputs) => + inputChanged(cacheStoreFactory.make("output")) { (outChanged, outputs: FilesInfo[PlainFileInfo]) => if (inChanged || outChanged) doCompile(sources, classpath, outputDirectory, options, maxErrors, log) diff --git a/main-actions/src/main/scala/sbt/Sync.scala b/main-actions/src/main/scala/sbt/Sync.scala index 143f84c43..8da6c68bc 100644 --- a/main-actions/src/main/scala/sbt/Sync.scala +++ b/main-actions/src/main/scala/sbt/Sync.scala @@ -81,13 +81,13 @@ object Sync { !target.exists || target.isDirectory != source.isDirectory - val updates = relation filter outofdate + val updates = relation.filter(outofdate) val (cleanDirs, cleanFiles) = (updates._2s ++ removeTargets).partition(_.isDirectory) IO.delete(cleanFiles) IO.deleteIfEmpty(cleanDirs) - updates.all.foreach((copy _).tupled) + updates.all.foreach((copy).tupled) writeInfoVirtual(store, relation, currentInfo, fileConverter)(inStyle.format) relation diff --git a/main-actions/src/main/scala/sbt/Tests.scala b/main-actions/src/main/scala/sbt/Tests.scala index ce0e9057d..14e6c4ee1 100644 --- a/main-actions/src/main/scala/sbt/Tests.scala +++ b/main-actions/src/main/scala/sbt/Tests.scala @@ -385,7 +385,7 @@ object Tests { testListeners: Vector[TestReportListener], config: Execution ): Task[Output] = { - def fj(actions: Iterable[() => Unit]): Task[Unit] = nop.dependsOn(actions.toSeq.fork(_()): _*) + def fj(actions: Iterable[() => Unit]): Task[Unit] = nop.dependsOn(actions.toSeq.fork(_())*) def partApp(actions: Iterable[ClassLoader => Unit]) = actions.toSeq map { a => () => a(loader) } @@ -399,7 +399,7 @@ object Tests { makeParallel(loader, runnables, setupTasks, config.tags).map(_.toList) else makeSerial(loader, runnables, setupTasks) - val taggedMainTasks = mainTasks.tagw(config.tags: _*) + val taggedMainTasks = mainTasks.tagw(config.tags*) taggedMainTasks .map(processResults) .flatMap { results => @@ -467,7 +467,7 @@ object Tests { Info[(String, (SuiteResult, Seq[TestTask]))]().setName(name), Action.Pure(() => (name, fun.apply()), `inline` = false) ) - val taggedBase = base.tagw(tags: _*).tag(fun.tags.map(ConcurrentRestrictions.Tag(_)): _*) + val taggedBase = base.tagw(tags*).tag(fun.tags.map(ConcurrentRestrictions.Tag(_))*) taggedBase flatMap { case (name, (result, nested)) => val nestedRunnables = createNestedRunnables(loader, fun, nested) toTasks(loader, nestedRunnables, tags).map { currentResultMap => @@ -509,7 +509,7 @@ object Tests { case Nil => acc } - task { processRunnable(runnables.toList, List.empty) } dependsOn (setupTasks) + task { processRunnable(runnables.toList, List.empty) }.dependsOn(setupTasks) } def processResults(results: Iterable[(String, SuiteResult)]): Output = @@ -531,7 +531,7 @@ object Tests { { case (Output(v1, m1, _), Output(v2, m2, _)) => Output( (if (severity(v1) < severity(v2)) v2 else v1): TestResult, - Map((m1.toSeq ++ m2.toSeq): _*), + Map((m1.toSeq ++ m2.toSeq)*), Iterable.empty[Summary] ) } @@ -550,7 +550,7 @@ object Tests { (e.overall, e.events) } val m = ms reduce { (m1: Map[String, SuiteResult], m2: Map[String, SuiteResult]) => - Map((m1.toSeq ++ m2.toSeq): _*) + Map((m1.toSeq ++ m2.toSeq)*) } Output(overall(rs), m, Iterable.empty) } diff --git a/main-actions/src/test/scala/sbt/CacheIvyTest.scala b/main-actions/src/test/scala/sbt/CacheIvyTest.scala index b78e3d537..759eab2e3 100644 --- a/main-actions/src/test/scala/sbt/CacheIvyTest.scala +++ b/main-actions/src/test/scala/sbt/CacheIvyTest.scala @@ -22,7 +22,7 @@ class CacheIvyTest extends Properties("CacheIvy") { import sjsonnew.support.scalajson.unsafe.Converter private class InMemoryStore(converter: SupportConverter[JValue]) extends CacheStore { - private var content: JValue = _ + private var content: JValue = scala.compiletime.uninitialized override def delete(): Unit = () override def close(): Unit = () @@ -131,6 +131,6 @@ class CacheIvyTest extends Properties("CacheIvy") { } import sbt.librarymanagement.LibraryManagementCodec._ - cachePreservesEquality(m, eq _, str) + cachePreservesEquality(m, eq, str) } } diff --git a/main-command/src/main/scala/sbt/BasicCommands.scala b/main-command/src/main/scala/sbt/BasicCommands.scala index 39c71e768..8b320c3f4 100644 --- a/main-command/src/main/scala/sbt/BasicCommands.scala +++ b/main-command/src/main/scala/sbt/BasicCommands.scala @@ -97,9 +97,9 @@ object BasicCommands { } private def earlyParser: State => Parser[String] = (s: State) => { - val p1 = token(EarlyCommand + "(") flatMap (_ => otherCommandParser(s) <~ token(")")) - val p2 = (token("-") | token("--")) flatMap (_ => levelParser) - val p3 = (token("-") | token("--")) flatMap (_ => addPluginSbtFileStringParser) + val p1 = token(EarlyCommand + "(").flatMap(_ => otherCommandParser(s) <~ token(")")) + val p2 = (token("-") | token("--")).flatMap(_ => levelParser) + val p3 = (token("-") | token("--")).flatMap(_ => addPluginSbtFileStringParser) p1 | p2 | p3 } @@ -280,8 +280,8 @@ object BasicCommands { lazy val otherCommandParser: State => Parser[String] = (s: State) => token(OptSpace ~> combinedLax(s, NotSpaceClass ~ any.*)) - def combinedLax(s: State, any: Parser[_]): Parser[String] = - matched((s.combinedParser: Parser[_]) | token(any, hide = const(true))) + def combinedLax(s: State, any: Parser[?]): Parser[String] = + matched((s.combinedParser: Parser[?]) | token(any, hide = const(true))) def ifLast: Command = Command(IfLast, Help.more(IfLast, IfLastDetailed))(otherCommandParser)((s, arg) => @@ -340,7 +340,7 @@ object BasicCommands { def argsStr = args mkString ", " def cpStr = cp mkString File.pathSeparator def fromCpStr = if (cp.isEmpty) "" else s" from $cpStr" - state.log info s"Applying State transformations $argsStr$fromCpStr" + state.log.info(s"Applying State transformations $argsStr$fromCpStr") val loader = if (cp.isEmpty) parentLoader else toLoader(cp.map(f => Paths.get(f)), parentLoader) val loaded = @@ -370,14 +370,14 @@ object BasicCommands { s.source match { case Some(c) if c.channelName.startsWith("network") => s"${DisconnectNetworkChannel} ${c.channelName}" :: s - case _ => s exit true + case _ => s.exit(true) } } def shutdown: Command = Command.command(Shutdown, shutdownBrief, shutdownBrief) { s => s.source match { case Some(c) if c.channelName.startsWith("network") => s"${DisconnectNetworkChannel} ${c.channelName}" :: (Exec(Shutdown, None) +: s) - case _ => s exit true + case _ => s.exit(true) } } @@ -395,7 +395,7 @@ object BasicCommands { def historyParser(s: State): Parser[() => State] = Command.applyEffect(HistoryCommands.actionParser) { histFun => - val hp = (s get historyPath).flatten + val hp = s.get(historyPath).flatten val lines = hp.toList.flatMap(p => IO.readLines(p)).toIndexedSeq histFun(CHistory(lines, hp)) match { case Some(commands) => @@ -406,8 +406,10 @@ object BasicCommands { } def oldshell: Command = Command.command(OldShell, Help.more(Shell, OldShellDetailed)) { s => - val history = (s get historyPath) getOrElse (new File(s.baseDir, ".history")).some - val prompt = (s get shellPrompt) match { case Some(pf) => pf(s); case None => "> " } + val history = s.get(historyPath).getOrElse(new File(s.baseDir, ".history").some) + val prompt = s.get(shellPrompt) match + case Some(pf) => pf(s) + case None => "> " val reader = new FullReader(history, s.combinedParser, LineReader.HandleCONT, Terminal.console) val line = reader.readLine(prompt) line match { @@ -427,7 +429,7 @@ object BasicCommands { Command(Client, Help.more(Client, ClientDetailed))(_ => clientParser)(runClient) def clientParser: Parser[Seq[String]] = - (token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF) map (_ => nilSeq)) + (token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF).map(_ => nilSeq)) def runClient(s0: State, inputArg: Seq[String]): State = { val arguments = inputArg.toList ++ @@ -485,7 +487,7 @@ object BasicCommands { def alias: Command = Command(AliasCommand, Help.more(AliasCommand, AliasDetailed)) { s => - val name = token(OpOrID.examples(aliasNames(s): _*)) + val name = token(OpOrID.examples(aliasNames(s)*)) val assign = token(OptSpace ~ '=' ~ OptSpace) val sfree = removeAliases(s) val to = matched(sfree.combinedParser, partial = true).failOnException | any.+.string @@ -500,13 +502,12 @@ object BasicCommands { case _ => printAliases(s); s } def addAlias(s: State, name: String, value: String): State = - if (Command validID name) { + if Command.validID(name) then val removed = removeAlias(s, name) - if (value.isEmpty) removed else addAlias0(removed, name, value) - } else { + if value.isEmpty then removed else addAlias0(removed, name, value) + else System.err.println("Invalid alias name '" + name + "'.") s.fail - } private def addAlias0(s: State, name: String, value: String): State = s.copy(definedCommands = newAlias(name, value) +: s.definedCommands) @@ -515,18 +516,18 @@ object BasicCommands { def removeAlias(s: State, name: String): State = s.copy(definedCommands = s.definedCommands.filter(c => !isAliasNamed(name, c))) - def removeTagged(s: State, tag: AttributeKey[_]): State = + def removeTagged(s: State, tag: AttributeKey[?]): State = s.copy(definedCommands = removeTagged(s.definedCommands, tag)) - def removeTagged(as: Seq[Command], tag: AttributeKey[_]): Seq[Command] = - as.filter(c => !(c.tags contains tag)) + def removeTagged(as: Seq[Command], tag: AttributeKey[?]): Seq[Command] = + as.filter(c => !(c.tags.contains(tag))) def isAliasNamed(name: String, c: Command): Boolean = isNamed(name, getAlias(c)) def isNamed(name: String, alias: Option[(String, String)]): Boolean = alias match { case None => false; case Some((n, _)) => name == n } - def getAlias(c: Command): Option[(String, String)] = c.tags get CommandAliasKey + def getAlias(c: Command): Option[(String, String)] = c.tags.get(CommandAliasKey) def printAlias(s: State, name: String): Unit = printAliases(aliases(s, (n, _) => n == name)) def printAliases(s: State): Unit = printAliases(allAliases(s)) diff --git a/main-command/src/main/scala/sbt/Command.scala b/main-command/src/main/scala/sbt/Command.scala index a94ae0d59..b76b3f27a 100644 --- a/main-command/src/main/scala/sbt/Command.scala +++ b/main-command/src/main/scala/sbt/Command.scala @@ -41,7 +41,7 @@ private[sbt] final class SimpleCommand( val tags: AttributeMap ) extends Command { - assert(Command validID name, s"'$name' is not a valid command name.") + assert(Command.validID(name), s"'$name' is not a valid command name.") def help = const(help0) @@ -104,7 +104,7 @@ object Command { /** Construct a single-argument command with the given name and effect. */ def single(name: String, help: Help = Help.empty)(f: (State, String) => State): Command = - make(name, help)(state => token(trimmed(spacedAny(name)) map apply1(f, state))) + make(name, help)(state => token(trimmed(spacedAny(name)).map(apply1(f, state)))) def single(name: String, briefHelp: (String, String), detail: String)( f: (State, String) => State @@ -117,7 +117,7 @@ object Command { def args(name: String, display: String, help: Help = Help.empty)( f: (State, Seq[String]) => State ): Command = - make(name, help)(state => spaceDelimited(display) map apply1(f, state)) + make(name, help)(state => spaceDelimited(display).map(apply1(f, state))) def args(name: String, briefHelp: (String, String), detail: String, display: String)( f: (State, Seq[String]) => State @@ -143,7 +143,7 @@ object Command { def validID(name: String): Boolean = DefaultParsers.matches(OpOrID, name) - def applyEffect[T](p: Parser[T])(f: T => State): Parser[() => State] = p map (t => () => f(t)) + def applyEffect[T](p: Parser[T])(f: T => State): Parser[() => State] = p.map(t => () => f(t)) def applyEffect[T]( parser: State => Parser[T] @@ -176,13 +176,11 @@ object Command { commandMap: Map[String, State => Parser[() => State]] ): State => Parser[() => State] = state => - token(OpOrID examples commandMap.keys.toSet) flatMap ( - id => - (commandMap get id) match { - case None => failure(invalidValue("command", commandMap.keys)(id)) - case Some(c) => c(state) - } - ) + token(OpOrID.examples(commandMap.keys.toSet)).flatMap: id => + (commandMap get id) match { + case None => failure(invalidValue("command", commandMap.keys)(id)) + case Some(c) => c(state) + } // overload instead of default parameter to keep binary compatibility @deprecated("Use overload that takes the onParseError callback", since = "1.9.4") @@ -250,7 +248,7 @@ private final class Help0( def ++(h: Help): Help = new Help0( Help0.this.brief ++ h.brief, - Map(Help0.this.detail.toSeq ++ h.detail.toSeq: _*), + Map(Help0.this.detail.toSeq ++ h.detail.toSeq*), more ++ h.more ) } diff --git a/main-command/src/main/scala/sbt/CommandUtil.scala b/main-command/src/main/scala/sbt/CommandUtil.scala index 6719be51b..d05d21951 100644 --- a/main-command/src/main/scala/sbt/CommandUtil.scala +++ b/main-command/src/main/scala/sbt/CommandUtil.scala @@ -46,7 +46,7 @@ object CommandUtil { def fill(s: String, size: Int): String = s + " " * math.max(size - s.length, 0) def withAttribute[T](s: State, key: AttributeKey[T], ifMissing: String)(f: T => State): State = - s get key match { + s.get(key) match { case None => s.log.error(ifMissing); s.fail case Some(nav) => f(nav) @@ -54,7 +54,7 @@ object CommandUtil { def singleArgument(exampleStrings: Set[String]): Parser[String] = { val arg = (NotSpaceClass ~ any.*) map { case (ns, s) => (ns +: s).mkString } - token(Space) ~> token(arg examples exampleStrings) + token(Space) ~> token(arg.examples(exampleStrings)) } def detail(selected: String, detailMap: Map[String, String]): String = diff --git a/main-command/src/main/scala/sbt/State.scala b/main-command/src/main/scala/sbt/State.scala index 834d89329..b7f99491f 100644 --- a/main-command/src/main/scala/sbt/State.scala +++ b/main-command/src/main/scala/sbt/State.scala @@ -179,13 +179,13 @@ trait StateOps extends Any { def put[T](key: AttributeKey[T], value: T): State /** Removes the `key` and any associated value from the custom attributes map. */ - def remove(key: AttributeKey[_]): State + def remove(key: AttributeKey[?]): State /** Sets the value associated with `key` in the custom attributes map by transforming the current value. */ def update[T](key: AttributeKey[T])(f: Option[T] => T): State /** Returns true if `key` exists in the custom attributes map, false if it does not exist. */ - def has(key: AttributeKey[_]): Boolean + def has(key: AttributeKey[?]): Boolean /** The application base directory, which is not necessarily the current working directory. */ def baseDir: File @@ -359,11 +359,11 @@ object State { def clearGlobalLog = setNext(ClearGlobalLog) def keepLastLog = setNext(KeepLastLog) def exit(ok: Boolean) = runExitHooks().setNext(new Return(Exit(if (ok) 0 else 1))) - def get[T](key: AttributeKey[T]) = s.attributes get key + def get[T](key: AttributeKey[T]) = s.attributes.get(key) def put[T](key: AttributeKey[T], value: T) = s.copy(attributes = s.attributes.put(key, value)) def update[T](key: AttributeKey[T])(f: Option[T] => T): State = put(key, f(get(key))) - def has(key: AttributeKey[_]) = s.attributes contains key - def remove(key: AttributeKey[_]) = s.copy(attributes = s.attributes remove key) + infix def has(key: AttributeKey[?]) = s.attributes.contains(key) + def remove(key: AttributeKey[?]) = s.copy(attributes = s.attributes.remove(key)) def log = s.globalLogging.full def handleError(t: Throwable): State = handleException(t, s, log) def fail = { @@ -397,13 +397,19 @@ object State { def setInteractive(i: Boolean) = s.put(BasicKeys.interactive, i) def classLoaderCache: IncClassLoaderCache = - s get BasicKeys.classLoaderCache getOrElse (throw new IllegalStateException( - "Tried to get classloader cache for uninitialized state." - )) + s.get(BasicKeys.classLoaderCache) + .getOrElse( + throw new IllegalStateException( + "Tried to get classloader cache for uninitialized state." + ) + ) private[sbt] def extendedClassLoaderCache: ClassLoaderCache = - s get BasicKeys.extendedClassLoaderCache getOrElse (throw new IllegalStateException( - "Tried to get extended classloader cache for uninitialized state." - )) + s.get(BasicKeys.extendedClassLoaderCache) + .getOrElse( + throw new IllegalStateException( + "Tried to get extended classloader cache for uninitialized state." + ) + ) def initializeClassLoaderCache: State = { s.get(BasicKeys.extendedClassLoaderCache).foreach(_.close()) val cache = newClassLoaderCache @@ -454,7 +460,7 @@ object State { private[sbt] def logFullException(e: Throwable, log: Logger): Unit = { e.printStackTrace(System.err) log.trace(e) - log.error(ErrorHandling reducedToString e) + log.error(ErrorHandling.reducedToString(e)) log.error("Use 'last' for the full log.") } private[sbt] def getBoolean(s: State, key: AttributeKey[Boolean], default: Boolean): Boolean = diff --git a/main-command/src/main/scala/sbt/internal/LegacyWatched.scala b/main-command/src/main/scala/sbt/internal/LegacyWatched.scala index bb423e7f0..0a2effde8 100644 --- a/main-command/src/main/scala/sbt/internal/LegacyWatched.scala +++ b/main-command/src/main/scala/sbt/internal/LegacyWatched.scala @@ -24,7 +24,7 @@ private[sbt] object LegacyWatched { @tailrec def shouldTerminate: Boolean = (System.in.available > 0) && (watched.terminateWatch(System.in.read()) || shouldTerminate) val log = s.log - s get ContinuousEventMonitor match { + s.get(ContinuousEventMonitor) match { case None => val watchState = WatchState.empty(watched.watchService(), watched.watchSources(s)) // This is the first iteration, so run the task and create a new EventMonitor @@ -45,7 +45,7 @@ private[sbt] object LegacyWatched { (ClearOnFailure :: next :: FailureWall :: repeat :: s) .put(ContinuousEventMonitor, monitor: EventMonitor) case Some(eventMonitor) => - Watched.printIfDefined(watched watchingMessage eventMonitor.state()) + Watched.printIfDefined(watched.watchingMessage(eventMonitor.state())) @tailrec def impl(): State = { val triggered = try eventMonitor.awaitEvent() @@ -58,7 +58,7 @@ private[sbt] object LegacyWatched { false } if (triggered) { - Watched.printIfDefined(watched triggeredMessage eventMonitor.state()) + Watched.printIfDefined(watched.triggeredMessage(eventMonitor.state())) ClearOnFailure :: next :: FailureWall :: repeat :: s } else if (shouldTerminate) { while (System.in.available() > 0) System.in.read() diff --git a/main-command/src/main/scala/sbt/internal/client/NetworkClient.scala b/main-command/src/main/scala/sbt/internal/client/NetworkClient.scala index 5fdf0f9cc..ae030ae9e 100644 --- a/main-command/src/main/scala/sbt/internal/client/NetworkClient.scala +++ b/main-command/src/main/scala/sbt/internal/client/NetworkClient.scala @@ -361,7 +361,7 @@ class NetworkClient( else Nil val processBuilder = - new ProcessBuilder((nohup ++ cmd): _*) + new ProcessBuilder((nohup ++ cmd)*) .directory(arguments.baseDirectory) .redirectInput(Redirect.PIPE) processBuilder.environment.put(Terminal.TERMINAL_PROPS, props) diff --git a/main-command/src/main/scala/sbt/internal/server/Server.scala b/main-command/src/main/scala/sbt/internal/server/Server.scala index 2e8390c0e..53cdc02a4 100644 --- a/main-command/src/main/scala/sbt/internal/server/Server.scala +++ b/main-command/src/main/scala/sbt/internal/server/Server.scala @@ -193,7 +193,7 @@ private[sbt] object Server { def acl(owner: UserPrincipal) = { val builder = AclEntry.newBuilder builder.setPrincipal(owner) - builder.setPermissions(AclEntryPermission.values(): _*) + builder.setPermissions(AclEntryPermission.values()*) builder.setType(AclEntryType.ALLOW) builder.build } diff --git a/main-command/src/main/scala/sbt/internal/ui/UITask.scala b/main-command/src/main/scala/sbt/internal/ui/UITask.scala index bab58fa5a..399ca6a2e 100644 --- a/main-command/src/main/scala/sbt/internal/ui/UITask.scala +++ b/main-command/src/main/scala/sbt/internal/ui/UITask.scala @@ -55,7 +55,7 @@ private[sbt] object UITask { object Reader { // Avoid filling the stack trace since it isn't helpful here object interrupted extends InterruptedException - def terminalReader(parser: Parser[_])( + def terminalReader(parser: Parser[?])( terminal: Terminal, state: State ): Reader = new Reader { diff --git a/main-settings/src/main/scala/sbt/Def.scala b/main-settings/src/main/scala/sbt/Def.scala index e9a19c34d..c4d48256b 100644 --- a/main-settings/src/main/scala/sbt/Def.scala +++ b/main-settings/src/main/scala/sbt/Def.scala @@ -57,43 +57,43 @@ end BuildSyntax object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: type Classpath = Seq[Attributed[HashedVirtualFileRef]] - def settings(ss: SettingsDefinition*): Seq[Setting[_]] = ss.flatMap(_.settings) + def settings(ss: SettingsDefinition*): Seq[Setting[?]] = ss.flatMap(_.settings) val onComplete = SettingKey[() => Unit]( "onComplete", "Hook to run when task evaluation completes. The type of this setting is subject to change, pending the resolution of SI-2915." ) // .withRank(DSetting) - val triggeredBy = AttributeKey[Seq[Task[_]]]("triggered-by") - val runBefore = AttributeKey[Seq[Task[_]]]("run-before") - val resolvedScoped = SettingKey[ScopedKey[_]]( + val triggeredBy = AttributeKey[Seq[Task[?]]]("triggered-by") + val runBefore = AttributeKey[Seq[Task[?]]]("run-before") + val resolvedScoped = SettingKey[ScopedKey[?]]( "resolved-scoped", "The ScopedKey for the referencing setting or task.", KeyRanks.DSetting ) - private[sbt] val taskDefinitionKey = AttributeKey[ScopedKey[_]]( + private[sbt] val taskDefinitionKey = AttributeKey[ScopedKey[?]]( "task-definition-key", "Internal: used to map a task back to its ScopedKey.", Invisible ) - lazy val showFullKey: Show[ScopedKey[_]] = showFullKey(None) + lazy val showFullKey: Show[ScopedKey[?]] = showFullKey(None) - def showFullKey(keyNameColor: Option[String]): Show[ScopedKey[_]] = - Show[ScopedKey[_]]((key: ScopedKey[_]) => displayFull(key, keyNameColor)) + def showFullKey(keyNameColor: Option[String]): Show[ScopedKey[?]] = + Show[ScopedKey[?]]((key: ScopedKey[?]) => displayFull(key, keyNameColor)) @deprecated("Use showRelativeKey2 which doesn't take the unused multi param", "1.1.1") def showRelativeKey( current: ProjectRef, multi: Boolean, keyNameColor: Option[String] = None - ): Show[ScopedKey[_]] = + ): Show[ScopedKey[?]] = showRelativeKey2(current, keyNameColor) def showRelativeKey2( current: ProjectRef, keyNameColor: Option[String] = None, - ): Show[ScopedKey[_]] = - Show[ScopedKey[_]](key => { + ): Show[ScopedKey[?]] = + Show[ScopedKey[?]](key => { val color: String => String = withColor(_, keyNameColor) key.scope.extra.toOption .flatMap(_.get(Scope.customShowString).map(color)) @@ -104,7 +104,7 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: private[sbt] def showShortKey( keyNameColor: Option[String], - ): Show[ScopedKey[_]] = { + ): Show[ScopedKey[?]] = { def displayShort( project: Reference ): String = { @@ -115,7 +115,7 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: case _ => Reference.display(project) + trailing } } - Show[ScopedKey[_]](key => + Show[ScopedKey[?]](key => Scope.display( key.scope, withColor(key.key.label, keyNameColor), @@ -129,14 +129,14 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: currentBuild: URI, multi: Boolean, keyNameColor: Option[String] = None, - ): Show[ScopedKey[_]] = + ): Show[ScopedKey[?]] = showBuildRelativeKey2(currentBuild, keyNameColor) def showBuildRelativeKey2( currentBuild: URI, keyNameColor: Option[String] = None, - ): Show[ScopedKey[_]] = - Show[ScopedKey[_]](key => + ): Show[ScopedKey[?]] = + Show[ScopedKey[?]](key => Scope.display( key.scope, withColor(key.key.label, keyNameColor), @@ -193,15 +193,15 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: case _ => Reference.display(project) + " /" } - def displayFull(scoped: ScopedKey[_]): String = displayFull(scoped, None) + def displayFull(scoped: ScopedKey[?]): String = displayFull(scoped, None) - def displayFull(scoped: ScopedKey[_], keyNameColor: Option[String]): String = + def displayFull(scoped: ScopedKey[?], keyNameColor: Option[String]): String = Scope.display(scoped.scope, withColor(scoped.key.label, keyNameColor)) - def displayMasked(scoped: ScopedKey[_], mask: ScopeMask): String = + def displayMasked(scoped: ScopedKey[?], mask: ScopeMask): String = Scope.displayMasked(scoped.scope, scoped.key.label, mask) - def displayMasked(scoped: ScopedKey[_], mask: ScopeMask, showZeroConfig: Boolean): String = + def displayMasked(scoped: ScopedKey[?], mask: ScopeMask, showZeroConfig: Boolean): String = Scope.displayMasked(scoped.scope, scoped.key.label, mask, showZeroConfig) def withColor(s: String, color: Option[String]): String = @@ -229,9 +229,9 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: else if (s1 == GlobalScope) Some(s2) // s2 is more specific else super.intersect(s1, s2) - private def definedSettingString(s: Setting[_]): String = + private def definedSettingString(s: Setting[?]): String = s"derived setting ${s.key.key.label}${positionString(s)}" - private def positionString(s: Setting[_]): String = + private def positionString(s: Setting[?]): String = s.positionString match { case None => ""; case Some(pos) => s" defined at $pos" } /** @@ -417,7 +417,7 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: inline def toTask(arg: String): Initialize[Task[A1]] = import TaskExtra.singleInputTask FullInstance.flatten( - (Def.stateKey zipWith in)((sTask, it) => + Def.stateKey.zipWith(in)((sTask, it) => sTask map { s => Parser.parse(arg, it.parser(s)) match case Right(a) => Def.value[Task[A1]](a) @@ -460,7 +460,7 @@ object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: base.copy(info = base.info.set(isDummyTask, true)) } - private[sbt] def isDummy(t: Task[_]): Boolean = + private[sbt] def isDummy(t: Task[?]): Boolean = t.info.attributes.get(isDummyTask) getOrElse false end Def diff --git a/main-settings/src/main/scala/sbt/InputTask.scala b/main-settings/src/main/scala/sbt/InputTask.scala index 117c0a3c0..e46fe3d7a 100644 --- a/main-settings/src/main/scala/sbt/InputTask.scala +++ b/main-settings/src/main/scala/sbt/InputTask.scala @@ -18,7 +18,7 @@ import sbt.util.Applicative /** Parses input and produces a task to run. Constructed using the companion object. */ final class InputTask[A1] private (val parser: State => Parser[Task[A1]]): def mapTask[S](f: Task[A1] => Task[S]): InputTask[S] = - InputTask[S](s => parser(s) map f) + InputTask[S](s => parser(s).map(f)) def partialInput(in: String): InputTask[A1] = InputTask[A1](s => Parser(parser(s))(in)) @@ -75,7 +75,7 @@ object InputTask: def free[A1](p: State => Parser[Task[A1]]): InputTask[A1] = make(p) def free[A1, A2](p: State => Parser[A1])(c: A1 => Task[A2]): InputTask[A2] = - free(s => p(s) map c) + free(s => p(s).map(c)) def separate[A1, A2]( p: State => Parser[A1] diff --git a/main-settings/src/main/scala/sbt/Plugins.scala b/main-settings/src/main/scala/sbt/Plugins.scala index 6fe00406e..0b9ebff1d 100644 --- a/main-settings/src/main/scala/sbt/Plugins.scala +++ b/main-settings/src/main/scala/sbt/Plugins.scala @@ -95,17 +95,17 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions { def projectConfigurations: Seq[Configuration] = Nil /** The `Setting`s to add in the scope of each project that activates this AutoPlugin. */ - def projectSettings: Seq[Setting[_]] = Nil + def projectSettings: Seq[Setting[?]] = Nil /** * The `Setting` to add to the build scope for each project that activates this AutoPlugin. * The settings returned here are guaranteed to be added to a given build scope only once * regardless of how many projects for that build activate this AutoPlugin. */ - def buildSettings: Seq[Setting[_]] = Nil + def buildSettings: Seq[Setting[?]] = Nil /** The `Setting`s to add to the global scope exactly once if any project activates this AutoPlugin. */ - def globalSettings: Seq[Setting[_]] = Nil + def globalSettings: Seq[Setting[?]] = Nil // TODO?: def commands: Seq[Command] @@ -113,7 +113,7 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions { def extraProjects: Seq[Project] = Nil /** The [[Project]]s to add to the current build based on an existing project. */ - def derivedProjects(@deprecated("unused", "") proj: ProjectDefinition[_]): Seq[Project] = Nil + def derivedProjects(@deprecated("unused", "") proj: ProjectDefinition[?]): Seq[Project] = Nil private[sbt] def unary_! : Exclude = Exclude(this) @@ -164,7 +164,7 @@ sealed trait PluginsFunctions { object Plugins extends PluginsFunctions { - private[sbt] var defaultRequires: Plugins = _ + private[sbt] var defaultRequires: Plugins = scala.compiletime.uninitialized /** * Given the available auto plugins `defined`, returns a function that selects [[AutoPlugin]]s for the provided [[AutoPlugin]]s. @@ -280,7 +280,7 @@ object Plugins extends PluginsFunctions { private def duplicateProvidesError(byAtom: Seq[(Atom, AutoPlugin)]): Unit = { val dupsByAtom = Map(byAtom.groupBy(_._1).toSeq.map { case (k, v) => k -> v.map(_._2) - }: _*) + }*) val dupStrings = for ((atom, dups) <- dupsByAtom if dups.size > 1) yield s"${atom.label} by ${dups.mkString(", ")}" @@ -437,7 +437,7 @@ ${listConflicts(conflicting)}""") import java.lang.reflect.Field import scala.util.control.Exception.catching // Make sure that we don't detect user-defined methods called autoImport - def existsAutoImportVal(clazz: Class[_]): Option[Field] = { + def existsAutoImportVal(clazz: Class[?]): Option[Field] = { catching(classOf[NoSuchFieldException]) .opt(clazz.getDeclaredField(autoImport)) .orElse(Option(clazz.getSuperclass).flatMap(existsAutoImportVal)) diff --git a/main-settings/src/main/scala/sbt/Previous.scala b/main-settings/src/main/scala/sbt/Previous.scala index 782ec74ff..43256f6af 100644 --- a/main-settings/src/main/scala/sbt/Previous.scala +++ b/main-settings/src/main/scala/sbt/Previous.scala @@ -43,7 +43,7 @@ object Previous { import sjsonnew.BasicJsonProtocol.StringJsonFormat private[sbt] type ScopedTaskKey[T] = ScopedKey[Task[T]] private type AnyTaskKey = ScopedTaskKey[Any] - private type Streams = sbt.std.Streams[ScopedKey[_]] + private type Streams = sbt.std.Streams[ScopedKey[?]] /** The stream where the task value is persisted. */ private final val StreamName = "previous" @@ -61,7 +61,7 @@ object Previous { def setTask(newTask: ScopedKey[Task[T]]) = new Referenced(newTask, format) private[sbt] def read(streams: Streams): Option[T] = - try Option(streams(key.cacheKey).cacheStoreFactory.make(StreamName).read[T]()(stamped)) + try Option(streams(key.cacheKey).cacheStoreFactory.make(StreamName).read[T]()(using stamped)) catch { case NonFatal(_) => None } } @@ -142,7 +142,7 @@ object Previous { ref <- map.get(key.asInstanceOf[Key[Any]]) } { val out = streams(key.cacheKey).cacheStoreFactory.make(StreamName) - try out.write(v)(ref.stamped) + try out.write(v)(using ref.stamped) catch { case NonFatal(_) => } } } @@ -154,8 +154,9 @@ object Previous { /** Public as a macro implementation detail. Do not call directly. */ def runtime[T](skey: TaskKey[T])(implicit format: JsonFormat[T]): Initialize[Task[Option[T]]] = { - val inputs = - (Global / cache) zip Def.validated(skey, selfRefOk = true) zip (Global / references) + val inputs = (Global / cache) + .zip(Def.validated(skey, selfRefOk = true)) + .zip(Global / references) inputs { case ((prevTask, resolved), refs) => val key = Key(resolved, resolved) refs.recordReference(key, format) // always evaluated on project load diff --git a/main-settings/src/main/scala/sbt/Project.scala b/main-settings/src/main/scala/sbt/Project.scala index 54203f419..27191d5f4 100644 --- a/main-settings/src/main/scala/sbt/Project.scala +++ b/main-settings/src/main/scala/sbt/Project.scala @@ -38,7 +38,7 @@ sealed trait ProjectDefinition[PR <: ProjectReference] { * The explicitly defined sequence of settings that configure this project. * These do not include the automatically appended settings as configured by `auto`. */ - def settings: Seq[Setting[_]] + def settings: Seq[Setting[?]] /** * The references to projects that are aggregated by this project. @@ -65,7 +65,7 @@ sealed trait ProjectDefinition[PR <: ProjectReference] { /** The [[AutoPlugin]]s enabled for this project. This value is only available on a loaded Project. */ private[sbt] def autoPlugins: Seq[AutoPlugin] - private[sbt] def commonSettings: Seq[Setting[_]] + private[sbt] def commonSettings: Seq[Setting[?]] override final def hashCode: Int = id.hashCode ^ base.hashCode ^ getClass.hashCode @@ -142,7 +142,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeP /** Appends settings to the current settings sequence for this project. */ def settings(ss: Def.SettingsDefinition*): Project = - copy(settings = (settings: Seq[Def.Setting[_]]) ++ Def.settings(ss: _*)) + copy(settings = (settings: Seq[Def.Setting[?]]) ++ Def.settings(ss*)) /** * Sets the [[AutoPlugin]]s of this project. @@ -163,7 +163,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeP /** Definitively set the [[ProjectOrigin]] for this project. */ private[sbt] def setProjectOrigin(origin: ProjectOrigin): Project = copy(projectOrigin = origin) - private[sbt] def setCommonSettings(settings: Seq[Setting[_]]): Project = + private[sbt] def setCommonSettings(settings: Seq[Setting[?]]): Project = copy(commonSettings = settings) /** @@ -177,15 +177,15 @@ sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeP def withId(id: String): Project = copy(id = id) /** Sets the base directory for this project. */ - def in(dir: File): Project = copy(base = dir) + infix def in(dir: File): Project = copy(base = dir) private[sbt] def copy( id: String = id, base: File = base, aggregate: Seq[ProjectReference] = aggregate, dependencies: Seq[ClasspathDep[ProjectReference]] = dependencies, - settings: Seq[Setting[_]] = settings, - commonSettings: Seq[Setting[_]] = commonSettings, + settings: Seq[Setting[?]] = settings, + commonSettings: Seq[Setting[?]] = commonSettings, configurations: Seq[Configuration] = configurations, plugins: Plugins = plugins, autoPlugins: Seq[AutoPlugin] = autoPlugins, @@ -255,8 +255,8 @@ object Project: val base: File, val aggregate: Seq[PR], val dependencies: Seq[ClasspathDep[PR]], - val settings: Seq[Def.Setting[_]], - val commonSettings: Seq[Def.Setting[_]], + val settings: Seq[Def.Setting[?]], + val commonSettings: Seq[Def.Setting[?]], val configurations: Seq[Configuration], val plugins: Plugins, val autoPlugins: Seq[AutoPlugin], @@ -273,8 +273,8 @@ object Project: base: File, aggregate: Seq[ProjectReference], dependencies: Seq[ClasspathDep[ProjectReference]], - settings: Seq[Def.Setting[_]], - commonSettings: Seq[Def.Setting[_]], + settings: Seq[Def.Setting[?]], + commonSettings: Seq[Def.Setting[?]], configurations: Seq[Configuration], plugins: Plugins, autoPlugins: Seq[AutoPlugin], @@ -301,8 +301,8 @@ object Project: base: File, aggregate: Seq[ProjectRef], dependencies: Seq[ClasspathDep[ProjectRef]], - settings: Seq[Def.Setting[_]], - commonSettings: Seq[Def.Setting[_]], + settings: Seq[Def.Setting[?]], + commonSettings: Seq[Def.Setting[?]], configurations: Seq[Configuration], plugins: Plugins, autoPlugins: Seq[AutoPlugin], @@ -328,23 +328,23 @@ object Project: private def validProjectIDStart(id: String): Boolean = DefaultParsers.parse(id, DefaultParsers.IDStart).isRight - def fillTaskAxis(scoped: ScopedKey[_]): ScopedKey[_] = + def fillTaskAxis(scoped: ScopedKey[?]): ScopedKey[?] = ScopedKey(Scope.fillTaskAxis(scoped.scope, scoped.key), scoped.key) def mapScope(f: Scope => Scope): [a] => ScopedKey[a] => ScopedKey[a] = [a] => (k: ScopedKey[a]) => ScopedKey(f(k.scope), k.key) - def transform(g: Scope => Scope, ss: Seq[Def.Setting[_]]): Seq[Def.Setting[_]] = + def transform(g: Scope => Scope, ss: Seq[Def.Setting[?]]): Seq[Def.Setting[?]] = val f = mapScope(g) ss.map { setting => setting.mapKey(f).mapReferenced(f) } - def transformRef(g: Scope => Scope, ss: Seq[Def.Setting[_]]): Seq[Def.Setting[_]] = + def transformRef(g: Scope => Scope, ss: Seq[Def.Setting[?]]): Seq[Def.Setting[?]] = val f = mapScope(g) - ss.map(_ mapReferenced f) + ss.map(_.mapReferenced(f)) - def inThisBuild(ss: Seq[Setting[_]]): Seq[Setting[_]] = + def inThisBuild(ss: Seq[Setting[?]]): Seq[Setting[?]] = inScope(ThisScope.copy(project = Select(ThisBuild)))(ss) private[sbt] def inThisBuild[T](i: Initialize[T]): Initialize[T] = @@ -353,13 +353,13 @@ object Project: private[sbt] def inConfig[T](conf: Configuration, i: Initialize[T]): Initialize[T] = inScope(ThisScope.copy(config = Select(conf)), i) - def inTask(t: Scoped)(ss: Seq[Setting[_]]): Seq[Setting[_]] = + def inTask(t: Scoped)(ss: Seq[Setting[?]]): Seq[Setting[?]] = inScope(ThisScope.copy(task = Select(t.key)))(ss) private[sbt] def inTask[A](t: Scoped, i: Initialize[A]): Initialize[A] = inScope(ThisScope.copy(task = Select(t.key)), i) - def inScope(scope: Scope)(ss: Seq[Setting[_]]): Seq[Setting[_]] = + def inScope(scope: Scope)(ss: Seq[Setting[?]]): Seq[Setting[?]] = Project.transform(Scope.replaceThis(scope), ss) private[sbt] def inScope[A](scope: Scope, i: Initialize[A]): Initialize[A] = diff --git a/main-settings/src/main/scala/sbt/Reference.scala b/main-settings/src/main/scala/sbt/Reference.scala index a9426a7b5..6bbaf449e 100644 --- a/main-settings/src/main/scala/sbt/Reference.scala +++ b/main-settings/src/main/scala/sbt/Reference.scala @@ -35,7 +35,7 @@ sealed trait Reference: final def /[K](key: Scoped.ScopingSetting[K]): K = key.rescope(asScope) - final def /(key: AttributeKey[_]): Scope = asScope.rescope(key) + final def /(key: AttributeKey[?]): Scope = asScope.rescope(key) end Reference /** A fully resolved, unique identifier for a project or build. */ @@ -85,11 +85,11 @@ object Reference { case (_: BuildRef, _: ProjectRef) => -1 case (_: ProjectRef, _: BuildRef) => 1 } - implicit val buildRefOrdering: Ordering[BuildRef] = (a, b) => a.build compareTo b.build + implicit val buildRefOrdering: Ordering[BuildRef] = (a, b) => a.build.compareTo(b.build) implicit val projectRefOrdering: Ordering[ProjectRef] = (a, b) => { - val bc = a.build compareTo b.build - if (bc == 0) a.project compareTo b.project else bc + val bc = a.build.compareTo(b.build) + if bc == 0 then a.project.compareTo(b.project) else bc } def display(ref: Reference): String = diff --git a/main-settings/src/main/scala/sbt/Scope.scala b/main-settings/src/main/scala/sbt/Scope.scala index 7ffa65779..b1cfc9a3c 100644 --- a/main-settings/src/main/scala/sbt/Scope.scala +++ b/main-settings/src/main/scala/sbt/Scope.scala @@ -18,7 +18,7 @@ import sbt.io.IO final case class Scope( project: ScopeAxis[Reference], config: ScopeAxis[ConfigKey], - task: ScopeAxis[AttributeKey[_]], + task: ScopeAxis[AttributeKey[?]], extra: ScopeAxis[AttributeMap] ): def rescope(project: Reference): Scope = copy(project = Select(project)) @@ -66,7 +66,7 @@ object Scope: case s => s } - def fillTaskAxis(scope: Scope, key: AttributeKey[_]): Scope = + def fillTaskAxis(scope: Scope, key: AttributeKey[?]): Scope = scope.task match { case _: Select[_] => scope case _ => scope.copy(task = Select(key)) @@ -103,7 +103,7 @@ object Scope: if (!uri.isAbsolute && current.isOpaque && uri.getSchemeSpecificPart == ".") current // this handles the shortcut of referring to the current build using "." else - IO.directoryURI(current resolve uri) + IO.directoryURI(current.resolve(uri)) def resolveReference( current: URI, @@ -264,7 +264,7 @@ object Scope: rootProject: URI => String, projectInherit: ProjectRef => Seq[ProjectRef], configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey], - taskInherit: AttributeKey[_] => Seq[AttributeKey[_]], + taskInherit: AttributeKey[?] => Seq[AttributeKey[?]], extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap] ): Scope => Seq[Scope] = delegates( @@ -285,7 +285,7 @@ object Scope: rootProject: URI => String, projectInherit: ProjectRef => Seq[ProjectRef], configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey], - taskInherit: AttributeKey[_] => Seq[AttributeKey[_]], + taskInherit: AttributeKey[?] => Seq[AttributeKey[?]], ): Scope => Seq[Scope] = { val index = delegates(refs, configurations, projectInherit, configInherit) scope => indexedDelegates(resolve, index, rootProject, taskInherit)(scope) @@ -296,7 +296,7 @@ object Scope: resolve: Reference => ResolvedReference, index: DelegateIndex, rootProject: URI => String, - taskInherit: AttributeKey[_] => Seq[AttributeKey[_]], + taskInherit: AttributeKey[?] => Seq[AttributeKey[?]], extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap] )(rawScope: Scope): Seq[Scope] = indexedDelegates(resolve, index, rootProject, taskInherit)(rawScope) @@ -305,7 +305,7 @@ object Scope: resolve: Reference => ResolvedReference, index: DelegateIndex, rootProject: URI => String, - taskInherit: AttributeKey[_] => Seq[AttributeKey[_]], + taskInherit: AttributeKey[?] => Seq[AttributeKey[?]], )(rawScope: Scope): Seq[Scope] = { val scope = Scope.replaceThis(GlobalScope)(rawScope) diff --git a/main-settings/src/main/scala/sbt/SlashSyntax.scala b/main-settings/src/main/scala/sbt/SlashSyntax.scala index 4991ce1a9..1a8d0e4ae 100644 --- a/main-settings/src/main/scala/sbt/SlashSyntax.scala +++ b/main-settings/src/main/scala/sbt/SlashSyntax.scala @@ -74,7 +74,7 @@ object SlashSyntax: } sealed trait HasSlashKeyOrAttrKey extends HasSlashKey { - def /(key: AttributeKey[_]): Scope = scope.rescope(key) + def /(key: AttributeKey[?]): Scope = scope.rescope(key) } /** RichReference wraps a reference to provide the `/` operator for scoping. */ @@ -91,7 +91,7 @@ object SlashSyntax: /** RichConfiguration wraps a configuration to provide the `/` operator for scoping. */ final class RichConfiguration(protected val scope: Scope) extends HasSlashKeyOrAttrKey { // This is for handling `Zero / Zero / Zero / name`. - def /(taskAxis: ScopeAxis[AttributeKey[_]]): Scope = + def /(taskAxis: ScopeAxis[AttributeKey[?]]): Scope = scope.copy(task = taskAxis) } diff --git a/main-settings/src/main/scala/sbt/Structure.scala b/main-settings/src/main/scala/sbt/Structure.scala index 7d94c8531..7986dc16d 100644 --- a/main-settings/src/main/scala/sbt/Structure.scala +++ b/main-settings/src/main/scala/sbt/Structure.scala @@ -23,7 +23,7 @@ import scala.reflect.ClassTag /** An abstraction on top of Settings for build configuration and task definition. */ sealed trait Scoped extends Equals: def scope: Scope - val key: AttributeKey[_] + val key: AttributeKey[?] override def equals(that: Any): Boolean = (this eq that.asInstanceOf[AnyRef]) || (that match { @@ -68,7 +68,7 @@ sealed abstract class SettingKey[A1] override def toString: String = s"SettingKey($scope / $key)" - final def toTask: Initialize[Task[A1]] = this apply inlineTask + final def toTask: Initialize[Task[A1]] = this.apply(inlineTask) final def scopedKey: ScopedKey[A1] = ScopedKey(scope, key) @@ -130,7 +130,7 @@ sealed abstract class SettingKey[A1] final def withRank(rank: Int): SettingKey[A1] = SettingKey(AttributeKey.copyWithRank(key, rank)) - def canEqual(that: Any): Boolean = that.isInstanceOf[SettingKey[_]] + def canEqual(that: Any): Boolean = that.isInstanceOf[SettingKey[?]] end SettingKey /** @@ -214,7 +214,7 @@ sealed abstract class TaskKey[A1] final def withRank(rank: Int): TaskKey[A1] = TaskKey(AttributeKey.copyWithRank(key, rank)) - def canEqual(that: Any): Boolean = that.isInstanceOf[TaskKey[_]] + def canEqual(that: Any): Boolean = that.isInstanceOf[TaskKey[?]] end TaskKey /** @@ -251,12 +251,12 @@ sealed trait InputKey[A1] final inline def ~=(f: A1 => A1): Setting[InputTask[A1]] = transform(f) final inline def transform(f: A1 => A1): Setting[InputTask[A1]] = - set(scopedKey(_ mapTask { _ map f })) + set(scopedKey(_ mapTask { _.map(f) })) final def withRank(rank: Int): InputKey[A1] = InputKey(AttributeKey.copyWithRank(key, rank)) - def canEqual(that: Any): Boolean = that.isInstanceOf[InputKey[_]] + def canEqual(that: Any): Boolean = that.isInstanceOf[InputKey[?]] end InputKey /** Methods and types related to constructing settings, including keys, scopes, and initializations. */ @@ -361,8 +361,8 @@ object Scoped: def doFinally(t: Task[Unit]): Initialize[Task[A1]] = onTask(_.doFinally(t)) def ||[T >: A1](alt: Task[T]): Initialize[Task[T]] = onTask(_ || alt) def &&[T](alt: Task[T]): Initialize[Task[T]] = onTask(_ && alt) - def tag(tags: Tag*): Initialize[Task[A1]] = onTask(_.tag(tags: _*)) - def tagw(tags: (Tag, Int)*): Initialize[Task[A1]] = onTask(_.tagw(tags: _*)) + def tag(tags: Tag*): Initialize[Task[A1]] = onTask(_.tag(tags*)) + def tagw(tags: (Tag, Int)*): Initialize[Task[A1]] = onTask(_.tagw(tags*)) // Task-specific extensions def dependsOn(tasks: Initialize[? <: Task[?]]*): Initialize[Task[A1]] = @@ -372,7 +372,7 @@ object Scoped: def dependsOnSeq(tasks: Seq[AnyInitTask]): Initialize[Task[A1]] = init.zipWith( Initialize.joinAny[Task](coerceToAnyTaskSeq(tasks)) - )((thisTask, deps) => thisTask.dependsOn(deps: _*)) + )((thisTask, deps) => thisTask.dependsOn(deps*)) def failure: Initialize[Task[Incomplete]] = init(_.failure) def result: Initialize[Task[Result[A1]]] = init(_.result) def triggeredBy[A2](tasks: Initialize[Task[A2]]*): Initialize[Task[A1]] = @@ -381,7 +381,7 @@ object Scoped: nonLocal(tasks.toSeq.asInstanceOf[Seq[AnyInitTask]], Def.runBefore) private def nonLocal( tasks: Seq[AnyInitTask], - key: AttributeKey[Seq[Task[_]]] + key: AttributeKey[Seq[Task[?]]] ): Initialize[Task[A1]] = Initialize .joinAny[Task](coerceToAnyTaskSeq(tasks)) @@ -390,26 +390,26 @@ object Scoped: extension [A1](init: Initialize[InputTask[A1]]) @targetName("onTaskInitializeInputTask") protected def onTask[T](f: Task[A1] => Task[T]): Initialize[InputTask[T]] = - init(_ mapTask f) + init(_.mapTask(f)) @targetName("flatMapTaskValueInitializeInputTask") def flatMapTaskValue[T](f: A1 => Task[T]): Initialize[InputTask[T]] = - onTask(_.result flatMap (f compose successM)) + onTask(_.result.flatMap(f compose successM)) @targetName("mapInitializeInputTask") def map[A2](f: A1 => A2): Initialize[InputTask[A2]] = - onTask(_.result map (f compose successM)) + onTask(_.result.map(f compose successM)) @targetName("andFinallyInitializeInputTask") - def andFinally(fin: => Unit): Initialize[InputTask[A1]] = onTask(_ andFinally fin) + def andFinally(fin: => Unit): Initialize[InputTask[A1]] = onTask(_.andFinally(fin)) @targetName("doFinallyInitializeInputTask") - def doFinally(t: Task[Unit]): Initialize[InputTask[A1]] = onTask(_ doFinally t) + def doFinally(t: Task[Unit]): Initialize[InputTask[A1]] = onTask(_.doFinally(t)) @targetName("||_InitializeInputTask") def ||[T >: A1](alt: Task[T]): Initialize[InputTask[T]] = onTask(_ || alt) @targetName("&&_InitializeInputTask") def &&[T](alt: Task[T]): Initialize[InputTask[T]] = onTask(_ && alt) @targetName("tagInitializeInputTask") - def tag(tags: Tag*): Initialize[InputTask[A1]] = onTask(_.tag(tags: _*)) + def tag(tags: Tag*): Initialize[InputTask[A1]] = onTask(_.tag(tags*)) @targetName("tagwInitializeInputTask") - def tagw(tags: (Tag, Int)*): Initialize[InputTask[A1]] = onTask(_.tagw(tags: _*)) + def tagw(tags: (Tag, Int)*): Initialize[InputTask[A1]] = onTask(_.tagw(tags*)) // InputTask specific extensions @targetName("dependsOnInitializeInputTask") @@ -423,7 +423,7 @@ object Scoped: @targetName("dependsOnSeqInitializeInputTask") def dependsOnSeq(tasks: Seq[AnyInitTask]): Initialize[InputTask[A1]] = init.zipWith(Initialize.joinAny[Task](coerceToAnyTaskSeq(tasks)))((thisTask, deps) => - thisTask.mapTask(_.dependsOn(deps: _*)) + thisTask.mapTask(_.dependsOn(deps*)) ) end Syntax @@ -456,7 +456,7 @@ object Scoped: inline def ~=(inline f: A1 => A1): Setting[Task[A1]] = transform(f) - inline def transform(f: A1 => A1): Setting[Task[A1]] = set(scopedKey(_ map f)) + inline def transform(f: A1 => A1): Setting[Task[A1]] = set(scopedKey(_.map(f))) def toSettingKey: SettingKey[Task[A1]] = scopedSetting(scope, key) @@ -494,7 +494,7 @@ object Scoped: private def coerceToAnyTaskSeq(tasks: Seq[AnyInitTask]): Seq[Def.Initialize[Task[Any]]] = tasks.asInstanceOf[Seq[Def.Initialize[Task[Any]]]] - type AnyInitTask = Initialize[Task[_]] + type AnyInitTask = Initialize[Task[?]] implicit def richTaskSeq[T](in: Seq[Initialize[Task[T]]]): RichTaskSeq[T] = new RichTaskSeq(in) final class RichTaskSeq[T](keys: Seq[Initialize[Task[T]]]) { @@ -507,7 +507,7 @@ object Scoped: def dependOn: Initialize[Task[Unit]] = Initialize .joinAny[Task](coerceToAnyTaskSeq(keys)) - .apply(deps => nop.dependsOn(deps: _*)) + .apply(deps => nop.dependsOn(deps*)) } sealed abstract class RichTaskables[Tup <: Tuple](final val keys: Tuple.Map[Tup, Taskable]): @@ -672,7 +672,7 @@ object Scoped: // format: on - private[sbt] def extendScoped(s1: Scoped, ss: Seq[Scoped]): Seq[AttributeKey[_]] = + private[sbt] def extendScoped(s1: Scoped, ss: Seq[Scoped]): Seq[AttributeKey[?]] = s1.key +: ss.map(_.key) end Scoped @@ -744,7 +744,7 @@ object InputKey: description: String, extend1: Scoped, extendN: Scoped* - ): InputKey[A1] = apply(label, description, KeyRanks.DefaultInputRank, extend1, extendN: _*) + ): InputKey[A1] = apply(label, description, KeyRanks.DefaultInputRank, extend1, extendN*) def apply[A1: ClassTag]( label: String, diff --git a/main-settings/src/main/scala/sbt/std/Instances.scala b/main-settings/src/main/scala/sbt/std/Instances.scala index 6a57ec725..b6ca657d1 100644 --- a/main-settings/src/main/scala/sbt/std/Instances.scala +++ b/main-settings/src/main/scala/sbt/std/Instances.scala @@ -87,7 +87,7 @@ object FullInstance: type Tup = (Task[Initialize[Task[A1]]], Task[SS], [a] => Initialize[a] => Initialize[a]) Def.app[Tup, Task[A1]]((in, settingsData, Def.capturedTransformations)) { case (a: Task[Initialize[Task[A1]]], data: Task[SS], f) => - TaskExtra.multT2Task((a, data)).flatMapN { case (a, d) => f(a) evaluate d } + TaskExtra.multT2Task((a, data)).flatMapN { case (a, d) => f(a).evaluate(d) } } def flattenFun[A1, A2]( @@ -96,7 +96,7 @@ object FullInstance: type Tup = (Task[A1 => Initialize[Task[A2]]], Task[SS], [a] => Initialize[a] => Initialize[a]) Def.app[Tup, A1 => Task[A2]]((in, settingsData, Def.capturedTransformations)) { case (a: Task[A1 => Initialize[Task[A2]]] @unchecked, data: Task[SS] @unchecked, f) => - (s: A1) => TaskExtra.multT2Task((a, data)).flatMapN { case (af, d) => f(af(s)) evaluate d } + (s: A1) => TaskExtra.multT2Task((a, data)).flatMapN { case (af, d) => f(af(s)).evaluate(d) } } end FullInstance diff --git a/main-settings/src/main/scala/sbt/std/KeyMacro.scala b/main-settings/src/main/scala/sbt/std/KeyMacro.scala index 653388433..1a8e2970d 100644 --- a/main-settings/src/main/scala/sbt/std/KeyMacro.scala +++ b/main-settings/src/main/scala/sbt/std/KeyMacro.scala @@ -70,9 +70,9 @@ private[sbt] object KeyMacro: import qctx.reflect._ def enclosingTerm0(sym: Symbol): Symbol = sym match - case sym if sym.flags is Flags.Macro => enclosingTerm0(sym.owner) - case sym if !sym.isTerm => enclosingTerm0(sym.owner) - case _ => sym + case sym if sym.flags.is(Flags.Macro) => enclosingTerm0(sym.owner) + case sym if !sym.isTerm => enclosingTerm0(sym.owner) + case _ => sym enclosingTerm0(Symbol.spliceOwner) private def enclosingClass(using Quotes) = diff --git a/main-settings/src/test/scala/sbt/AppendSpec.scala b/main-settings/src/test/scala/sbt/AppendSpec.scala index 1b97b363b..7b224f5b1 100644 --- a/main-settings/src/test/scala/sbt/AppendSpec.scala +++ b/main-settings/src/test/scala/sbt/AppendSpec.scala @@ -25,7 +25,7 @@ object AppendSpec { s } - Global / onLoad += doSideEffect _ + Global / onLoad += (() => doSideEffect()) Global / onLoad += (() => doSideEffect()) Global / onLoad += (() => println("foo")) } diff --git a/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala b/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala index d14a46b0b..1161f8894 100644 --- a/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala +++ b/main-settings/src/test/scala/sbt/SlashSyntaxTest.scala @@ -37,7 +37,7 @@ object SlashSyntaxTest extends sbt.SlashSyntax { val uTest = "com.lihaoyi" %% "utest" % "0.5.3" - Seq[Setting[_]]( + Seq[Setting[?]]( Global / cancelable := true, ThisBuild / scalaVersion := "2.12.3", console / scalacOptions += "-deprecation", diff --git a/main-settings/src/test/scala/sbt/std/TaskPosSpec.scala b/main-settings/src/test/scala/sbt/std/TaskPosSpec.scala index 6929b3105..bd7b774f2 100644 --- a/main-settings/src/test/scala/sbt/std/TaskPosSpec.scala +++ b/main-settings/src/test/scala/sbt/std/TaskPosSpec.scala @@ -129,7 +129,7 @@ class TaskPosSpec { import sbt._, Def._ val foo = taskKey[String]("") Def.task[String] { - def inner(s: KeyedInitialize[_]) = println(s) + def inner(s: KeyedInitialize[?]) = println(s) inner(foo) "" } diff --git a/main-settings/src/test/scala/sbt/std/UsageTest.scala b/main-settings/src/test/scala/sbt/std/UsageTest.scala index b9a7ab6ca..1fff7c01d 100644 --- a/main-settings/src/test/scala/sbt/std/UsageTest.scala +++ b/main-settings/src/test/scala/sbt/std/UsageTest.scala @@ -45,7 +45,7 @@ object Assign { val bk = taskKey[Seq[Int]]("b") val ck = settingKey[File]("c") val intTask = taskKey[Int]("int") - val sk = taskKey[Set[_]]("s") + val sk = taskKey[Set[?]]("s") val bgList = taskKey[Seq[Int]]("") val ik = inputKey[Int]("i") diff --git a/main/src/main/scala/sbt/BackgroundJobService.scala b/main/src/main/scala/sbt/BackgroundJobService.scala index e268b96ce..632ac2e9f 100644 --- a/main/src/main/scala/sbt/BackgroundJobService.scala +++ b/main/src/main/scala/sbt/BackgroundJobService.scala @@ -27,7 +27,7 @@ abstract class BackgroundJobService extends Closeable { * then you should get an InterruptedException while blocking on the process, and * then you could process.destroy() for example. */ - def runInBackground(spawningTask: ScopedKey[_], state: State)( + def runInBackground(spawningTask: ScopedKey[?], state: State)( start: (Logger, File) => Unit ): JobHandle @@ -40,7 +40,7 @@ abstract class BackgroundJobService extends Closeable { * then you should get an InterruptedException while blocking on the process, and * then you could process.destroy() for example. */ - private[sbt] def runInBackgroundWithLoader(spawningTask: ScopedKey[_], state: State)( + private[sbt] def runInBackgroundWithLoader(spawningTask: ScopedKey[?], state: State)( start: (Logger, File) => (Option[ClassLoader], () => Unit) ): JobHandle = runInBackground(spawningTask, state) { (logger, file) => start(logger, file)._2.apply() @@ -95,7 +95,7 @@ object BackgroundJobService { import DefaultParsers._ (state, handles) => { val stringIdParser: Parser[Seq[String]] = Space ~> token( - NotSpace examples handles.map(_.id.toString).toSet, + NotSpace.examples(handles.map(_.id.toString).toSet), description = "" ).+ stringIdParser.map { strings => @@ -108,7 +108,7 @@ object BackgroundJobService { abstract class JobHandle { def id: Long def humanReadableName: String - def spawningTask: ScopedKey[_] + def spawningTask: ScopedKey[?] } /** diff --git a/main/src/main/scala/sbt/BuildPaths.scala b/main/src/main/scala/sbt/BuildPaths.scala index bcef8cee8..51f27c7ff 100644 --- a/main/src/main/scala/sbt/BuildPaths.scala +++ b/main/src/main/scala/sbt/BuildPaths.scala @@ -76,7 +76,7 @@ object BuildPaths { def getFileSetting(stateKey: AttributeKey[File], property: String, default: => File)( state: State ): File = - state get stateKey orElse getFileProperty(property) getOrElse default + state.get(stateKey).orElse(getFileProperty(property)).getOrElse(default) def getFileProperty(name: String): Option[File] = Option(System.getProperty(name)) flatMap { path => diff --git a/main/src/main/scala/sbt/Cross.scala b/main/src/main/scala/sbt/Cross.scala index d3daa2b6b..3fb8ffdbc 100644 --- a/main/src/main/scala/sbt/Cross.scala +++ b/main/src/main/scala/sbt/Cross.scala @@ -45,7 +45,7 @@ object Cross { val x = Project.extract(state) import x._ val knownVersions = crossVersions(x, currentRef) - val version = token(StringBasic.examples(knownVersions: _*)).map { arg => + val version = token(StringBasic.examples(knownVersions*)).map { arg => val force = arg.endsWith("!") val versionArg = if (force) arg.dropRight(1) else arg versionArg.split("=", 2) match { @@ -105,9 +105,9 @@ object Cross { private def crossVersions(extracted: Extracted, proj: ResolvedReference): Seq[String] = { import extracted._ - ((proj / crossScalaVersions) get structure.data) getOrElse { + (proj / crossScalaVersions).get(structure.data).getOrElse { // reading scalaVersion is a one-time deal - ((proj / scalaVersion) get structure.data).toSeq + (proj / scalaVersion).get(structure.data).toSeq } } @@ -171,7 +171,7 @@ object Cross { Seq(s"$SwitchCommand $verbose $version!", aggCommand) } case Right((keys, taskArgs)) => - def project(key: ScopedKey[_]): Option[ProjectRef] = key.scope.project.toOption match { + def project(key: ScopedKey[?]): Option[ProjectRef] = key.scope.project.toOption match { case Some(p: ProjectRef) => Some(p) case _ => None } @@ -226,7 +226,7 @@ object Cross { restoreCapturedSession(state, Project.extract(state)) } - private val CapturedSession = AttributeKey[Seq[Setting[_]]]("crossCapturedSession") + private val CapturedSession = AttributeKey[Seq[Setting[?]]]("crossCapturedSession") private def captureCurrentSession(state: State, extracted: Extracted): State = { state.put(CapturedSession, extracted.session.rawAppend) @@ -279,7 +279,7 @@ object Cross { case ScalaHomeVersion(homePath, resolveVersion, _) => val home = IO.resolve(extracted.currentProject.base, homePath) if (home.exists()) { - val instance = ScalaInstance(home)(state.classLoaderCache.apply _) + val instance = ScalaInstance(home)(state.classLoaderCache.apply) val version = resolveVersion.getOrElse(instance.actualVersion) (version, Some((home, instance))) } else { @@ -414,7 +414,7 @@ object Cross { } } - val filterKeys: Set[AttributeKey[_]] = Set(scalaVersion, scalaHome, scalaInstance).map(_.key) + val filterKeys: Set[AttributeKey[?]] = Set(scalaVersion, scalaHome, scalaInstance).map(_.key) val projectsContains: Reference => Boolean = projects.map(_._1).toSet.contains diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index c337876df..750f0de08 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -153,17 +153,17 @@ object Defaults extends BuildCommon { def lock(app: xsbti.AppConfiguration): xsbti.GlobalLock = LibraryManagement.lock(app) - private[sbt] def globalDefaults(ss: Seq[Setting[_]]): Seq[Setting[_]] = + private[sbt] def globalDefaults(ss: Seq[Setting[?]]): Seq[Setting[?]] = Def.defaultSettings(inScope(GlobalScope)(ss)) - def buildCore: Seq[Setting[_]] = thisBuildCore ++ globalCore - def thisBuildCore: Seq[Setting[_]] = + def buildCore: Seq[Setting[?]] = thisBuildCore ++ globalCore + def thisBuildCore: Seq[Setting[?]] = inScope(GlobalScope.copy(project = Select(ThisBuild)))( Seq( managedDirectory := baseDirectory.value / "lib_managed" ) ) - private[sbt] lazy val globalCore: Seq[Setting[_]] = globalDefaults( + private[sbt] lazy val globalCore: Seq[Setting[?]] = globalDefaults( defaultTestTasks(test) ++ defaultTestTasks(testOnly) ++ defaultTestTasks(testQuick) ++ Seq( excludeFilter :== HiddenFileFilter, fileInputs :== Nil, @@ -181,9 +181,11 @@ object Defaults extends BuildCommon { ) ++ globalIvyCore ++ globalJvmCore ++ Watch.defaults ) ++ globalSbtCore - private[sbt] lazy val globalJvmCore: Seq[Setting[_]] = + private[sbt] lazy val globalJvmCore: Seq[Setting[?]] = Seq( - compilerCache := state.value get Keys.stateCompilerCache getOrElse CompilerCache.fresh, + compilerCache := state.value + .get(Keys.stateCompilerCache) + .getOrElse(CompilerCache.fresh), sourcesInBase :== true, autoAPIMappings := false, apiMappings := Map.empty, @@ -252,9 +254,9 @@ object Defaults extends BuildCommon { "JAVA_HOME" -> javaHome ) - private[sbt] lazy val globalIvyCore: Seq[Setting[_]] = + private[sbt] lazy val globalIvyCore: Seq[Setting[?]] = Seq( - internalConfigurationMap :== Configurations.internalMap _, + internalConfigurationMap :== Configurations.internalMap, credentials :== SysProp.sbtCredentialsEnv.toList, exportJars :== true, trackInternalDependencies :== TrackLevel.TrackAlways, @@ -302,7 +304,7 @@ object Defaults extends BuildCommon { ) /** Core non-plugin settings for sbt builds. These *must* be on every build or the sbt engine will fail to run at all. */ - private[sbt] lazy val globalSbtCore: Seq[Setting[_]] = globalDefaults( + private[sbt] lazy val globalSbtCore: Seq[Setting[?]] = globalDefaults( Seq( outputStrategy :== None, // TODO - This might belong elsewhere. buildStructure := Project.structure(state.value), @@ -332,11 +334,11 @@ object Defaults extends BuildCommon { finally IO.delete(taskTemporaryDirectory.value) }, // // extraLoggers is deprecated - SettingKey[ScopedKey[_] => Seq[XAppender]]("extraLoggers") :== { _ => + SettingKey[ScopedKey[?] => Seq[XAppender]]("extraLoggers") :== { _ => Nil }, extraAppenders := { - val f = SettingKey[ScopedKey[_] => Seq[XAppender]]("extraLoggers").value + val f = SettingKey[ScopedKey[?] => Seq[XAppender]]("extraLoggers").value s => f(s).map { case a: Appender => a @@ -426,7 +428,7 @@ object Defaults extends BuildCommon { ++ RemoteCache.globalSettings ) - private[sbt] lazy val buildLevelJvmSettings: Seq[Setting[_]] = Seq( + private[sbt] lazy val buildLevelJvmSettings: Seq[Setting[?]] = Seq( exportPipelining := usePipelining.value, sourcePositionMappers := Nil, // Never set a default sourcePositionMapper, see #6352! Whatever you are trying to solve, do it in the foldMappers method. // The virtual file value cache needs to be global or sbt will run out of direct byte buffer memory. @@ -526,7 +528,7 @@ object Defaults extends BuildCommon { .getOrElse(pos) } - def defaultTestTasks(key: Scoped): Seq[Setting[_]] = + def defaultTestTasks(key: Scoped): Seq[Setting[?]] = inTask(key)( Seq( tags := Seq(Tags.Test -> 1), @@ -535,7 +537,7 @@ object Defaults extends BuildCommon { ) // TODO: This should be on the new default settings for a project. - def projectCore: Seq[Setting[_]] = Seq( + def projectCore: Seq[Setting[?]] = Seq( name := thisProject.value.id, logManager := LogManager.defaults(extraAppenders.value, ConsoleOut.terminalOut), onLoadMessage := (onLoadMessage or @@ -545,7 +547,7 @@ object Defaults extends BuildCommon { ) // Appended to JvmPlugin.projectSettings - def paths: Seq[Setting[_]] = Seq( + def paths: Seq[Setting[?]] = Seq( baseDirectory := thisProject.value.base, target := rootOutputDirectory.value.resolve(outputPath.value).toFile(), // Use a different history path for jline3 because the jline2 format is @@ -652,7 +654,7 @@ object Defaults extends BuildCommon { ) // This exists for binary compatibility and probably never should have been public. def addBaseSources: Seq[Def.Setting[Task[Seq[File]]]] = Nil - lazy val outputConfigPaths: Seq[Setting[_]] = Seq( + lazy val outputConfigPaths: Seq[Setting[?]] = Seq( classDirectory := target.value / (prefix(configuration.value.name) + "classes"), backendOutput := { val converter = fileConverter.value @@ -684,7 +686,7 @@ object Defaults extends BuildCommon { // Scala 2.10 shades jline in the console so we need to make sure that it loads a compatible // jansi version. Because of the shading, console does not work with the thin client for 2.10.x. if (scalaVersion.value.startsWith("2.10.")) new ClassLoader(topLoader) { - override protected def loadClass(name: String, resolve: Boolean): Class[_] = { + override protected def loadClass(name: String, resolve: Boolean): Class[?] = { if (name.startsWith("org.fusesource")) throw new ClassNotFoundException(name) super.loadClass(name, resolve) } @@ -735,7 +737,7 @@ object Defaults extends BuildCommon { console / classpathOptions := ClasspathOptionsUtil.replNoboot(scalaVersion.value), ) // must be a val: duplication detected by object identity - private lazy val compileBaseGlobal: Seq[Setting[_]] = globalDefaults( + private lazy val compileBaseGlobal: Seq[Setting[?]] = globalDefaults( Seq( auxiliaryClassFiles :== Nil, incOptions := IncOptions.of(), @@ -872,7 +874,7 @@ object Defaults extends BuildCommon { } } - def defaultCompileSettings: Seq[Setting[_]] = + def defaultCompileSettings: Seq[Setting[?]] = globalDefaults( Seq( enableBinaryCompileAnalysis :== true, @@ -880,7 +882,7 @@ object Defaults extends BuildCommon { ) ) - lazy val configTasks: Seq[Setting[_]] = docTaskSettings(doc) ++ + lazy val configTasks: Seq[Setting[?]] = docTaskSettings(doc) ++ inTask(compile)(compileInputsSettings) ++ inTask(compileJava)( Seq( @@ -1063,7 +1065,7 @@ object Defaults extends BuildCommon { ) ) - lazy val projectTasks: Seq[Setting[_]] = Seq( + lazy val projectTasks: Seq[Setting[?]] = Seq( cleanFiles := cleanFilesTask.value, cleanKeepFiles := Vector.empty, cleanKeepGlobs ++= historyPath.value.map(_.toGlob).toVector, @@ -1118,7 +1120,7 @@ object Defaults extends BuildCommon { override def triggeredMessage(s: WatchState) = trigMsg(s) override def watchService() = getService() override def watchSources(s: State) = - EvaluateTask(Project structure s, key, s, base) match + EvaluateTask(Project.structure(s), key, s, base) match case Some((_, Result.Value(ps))) => ps case Some((_, Result.Inc(i))) => throw i case None => sys.error("key not found: " + Def.displayFull(key)) @@ -1312,11 +1314,11 @@ object Defaults extends BuildCommon { testOptions :== Nil, testOptionDigests := Nil, testResultLogger :== TestResultLogger.Default, - testOnly / testFilter :== (IncrementalTest.selectedFilter _), + testOnly / testFilter :== (IncrementalTest.selectedFilter), extraTestDigests :== Nil, ) ) - lazy val testTasks: Seq[Setting[_]] = + lazy val testTasks: Seq[Setting[?]] = testTaskOptions(test) ++ testTaskOptions(testOnly) ++ testTaskOptions( testQuick ) ++ testDefaults ++ Seq( @@ -1403,7 +1405,7 @@ object Defaults extends BuildCommon { */ lazy val ConfigZero: Scope = ThisScope.copy(config = Zero) lazy val ConfigGlobal: Scope = ConfigZero - def testTaskOptions(key: Scoped): Seq[Setting[_]] = + def testTaskOptions(key: Scoped): Seq[Setting[?]] = inTask(key)( Seq( testListeners := { @@ -1503,7 +1505,7 @@ object Defaults extends BuildCommon { } @nowarn - def inputTests(key: InputKey[_]): Initialize[InputTask[Unit]] = + def inputTests(key: InputKey[?]): Initialize[InputTask[Unit]] = inputTests0.mapReferenced(Def.mapScope((s) => s.rescope(key.key))) private lazy val inputTests0: Initialize[InputTask[Unit]] = { @@ -1513,9 +1515,9 @@ object Defaults extends BuildCommon { val filter = testFilter.value val config = testExecution.value val st = state.value - given display: Show[ScopedKey[_]] = Project.showContextKey(st) + given display: Show[ScopedKey[?]] = Project.showContextKey(st) val modifiedOpts = - Tests.Filters(filter(selected)) +: Tests.Argument(frameworkOptions: _*) +: config.options + Tests.Filters(filter(selected)) +: Tests.Argument(frameworkOptions*) +: config.options val newConfig = config.copy(options = modifiedOpts) val output = allTestGroupsTask( s, @@ -1649,7 +1651,7 @@ object Defaults extends BuildCommon { converter, opts, s.log, - (Tags.ForkedTestGroup, 1) +: group.tags: _* + (Tags.ForkedTestGroup, 1) +: group.tags* ) case Tests.InProcess => if (javaOptions.nonEmpty) { @@ -1732,16 +1734,16 @@ object Defaults extends BuildCommon { Nil } - lazy val packageBase: Seq[Setting[_]] = Seq( + lazy val packageBase: Seq[Setting[?]] = Seq( artifact := Artifact(moduleName.value) ) ++ Defaults.globalDefaults( Seq( packageOptions :== Nil, - artifactName :== (Artifact.artifactName _) + artifactName :== (Artifact.artifactName) ) ) - lazy val packageConfig: Seq[Setting[_]] = + lazy val packageConfig: Seq[Setting[?]] = inTask(packageBin)( Seq( packageOptions := { @@ -2252,7 +2254,7 @@ object Defaults extends BuildCommon { () } - def docTaskSettings(key: TaskKey[File] = doc): Seq[Setting[_]] = + def docTaskSettings(key: TaskKey[File] = doc): Seq[Setting[?]] = inTask(key)( Seq( apiMappings ++= { @@ -2378,7 +2380,7 @@ object Defaults extends BuildCommon { def consoleTask: Initialize[Task[Unit]] = consoleTask(fullClasspath, console) def consoleQuickTask = consoleTask(externalDependencyClasspath, consoleQuick) - def consoleTask(classpath: TaskKey[Classpath], task: TaskKey[_]): Initialize[Task[Unit]] = + def consoleTask(classpath: TaskKey[Classpath], task: TaskKey[?]): Initialize[Task[Unit]] = Def.task { val si = (task / scalaInstance).value val s = streams.value @@ -2604,9 +2606,9 @@ object Defaults extends BuildCommon { ) } - def compileInputsSettings: Seq[Setting[_]] = + def compileInputsSettings: Seq[Setting[?]] = compileInputsSettings(dependencyPicklePath) - def compileInputsSettings(classpathTask: TaskKey[Classpath]): Seq[Setting[_]] = { + def compileInputsSettings(classpathTask: TaskKey[Classpath]): Seq[Setting[?]] = { Seq( compileOptions := { val c = fileConverter.value @@ -2699,7 +2701,7 @@ object Defaults extends BuildCommon { private[sbt] def none[A]: Option[A] = (None: Option[A]) private[sbt] def jnone[A]: Optional[A] = none[A].toOptional - def compileAnalysisSettings: Seq[Setting[_]] = Seq( + def compileAnalysisSettings: Seq[Setting[?]] = Seq( previousCompile := { val setup = compileIncSetup.value val store = analysisStore(compileAnalysisFile) @@ -2779,7 +2781,7 @@ object Defaults extends BuildCommon { def runMainParser: (State, Seq[String]) => Parser[(String, Seq[String])] = { import DefaultParsers._ (state, mainClasses) => - Space ~> token(NotSpace examples mainClasses.toSet) ~ spaceDelimited("") + Space ~> token(NotSpace.examples(mainClasses.toSet)) ~ spaceDelimited("") } def testOnlyParser: (State, Seq[String]) => Parser[(Seq[String], Seq[String])] = { @@ -2793,9 +2795,9 @@ object Defaults extends BuildCommon { private def distinctParser(exs: Set[String], raw: Boolean): Parser[Seq[String]] = { import DefaultParsers._ import Parser.and - val base = token(Space) ~> token(and(NotSpace, not("--", "Unexpected: ---")) examples exs) + val base = token(Space) ~> token(and(NotSpace, not("--", "Unexpected: ---")).examples(exs)) val recurse = base flatMap { ex => - val (matching, notMatching) = exs.partition(GlobFilter(ex).accept _) + val (matching, notMatching) = exs.partition(GlobFilter(ex).accept) distinctParser(notMatching, raw) map { result => if (raw) ex +: result else matching.toSeq ++ result } @@ -2812,36 +2814,36 @@ object Defaults extends BuildCommon { // 1. runnerSettings is added unscoped via JvmPlugin. // 2. In addition it's added scoped to run task. - lazy val runnerSettings: Seq[Setting[_]] = Seq(runnerTask, forkOptions := forkOptionsTask.value) - private lazy val newRunnerSettings: Seq[Setting[_]] = + lazy val runnerSettings: Seq[Setting[?]] = Seq(runnerTask, forkOptions := forkOptionsTask.value) + private lazy val newRunnerSettings: Seq[Setting[?]] = Seq(runner := ClassLoaders.runner.value, forkOptions := forkOptionsTask.value) - lazy val baseTasks: Seq[Setting[_]] = projectTasks ++ packageBase + lazy val baseTasks: Seq[Setting[?]] = projectTasks ++ packageBase - lazy val configSettings: Seq[Setting[_]] = + lazy val configSettings: Seq[Setting[?]] = Classpaths.configSettings ++ configTasks ++ configPaths ++ packageConfig ++ Classpaths.compilerPluginConfig ++ deprecationSettings ++ BuildServerProtocol.configSettings - lazy val compileSettings: Seq[Setting[_]] = + lazy val compileSettings: Seq[Setting[?]] = configSettings ++ (mainBgRunMainTask +: mainBgRunTask) ++ Classpaths.addUnmanagedLibrary - lazy val testSettings: Seq[Setting[_]] = configSettings ++ testTasks + lazy val testSettings: Seq[Setting[?]] = configSettings ++ testTasks @nowarn @deprecated( "Create a separate subproject instead of using IntegrationTest and in addition avoid using itSettings", "1.9.0" ) - lazy val itSettings: Seq[Setting[_]] = inConfig(IntegrationTest) { + lazy val itSettings: Seq[Setting[?]] = inConfig(IntegrationTest) { testSettings } - lazy val defaultConfigs: Seq[Setting[_]] = inConfig(Compile)(compileSettings) ++ + lazy val defaultConfigs: Seq[Setting[?]] = inConfig(Compile)(compileSettings) ++ inConfig(Test)(testSettings) ++ inConfig(Runtime)(Classpaths.configSettings) // These are project level settings that MUST be on every project. - lazy val coreDefaultSettings: Seq[Setting[_]] = + lazy val coreDefaultSettings: Seq[Setting[?]] = projectCore ++ disableAggregation ++ Seq( // Missing but core settings baseDirectory := thisProject.value.base, @@ -2855,7 +2857,7 @@ object Defaults extends BuildCommon { publishM2 / skip := (publish / skip).value ) // build.sbt is treated a Scala source of metabuild, so to enable deprecation flag on build.sbt we set the option here. - lazy val deprecationSettings: Seq[Setting[_]] = + lazy val deprecationSettings: Seq[Setting[?]] = inConfig(Compile)( Seq( scalacOptions := { @@ -2921,7 +2923,7 @@ object Classpaths { concatSettings(a: Initialize[Seq[T]], b) // forward to widened variant // Included as part of JvmPlugin#projectSettings. - lazy val configSettings: Seq[Setting[_]] = classpaths ++ Seq( + lazy val configSettings: Seq[Setting[?]] = classpaths ++ Seq( products := makeProducts.value, pickleProducts := makePickleProducts.value, productDirectories := classDirectory.value :: Nil, @@ -2932,7 +2934,7 @@ object Classpaths { update.value ) ) - private def classpaths: Seq[Setting[_]] = + private def classpaths: Seq[Setting[?]] = Seq( externalDependencyClasspath := concat(unmanagedClasspath, managedClasspath).value, dependencyClasspath := concat(internalDependencyClasspath, externalDependencyClasspath).value, @@ -3080,13 +3082,13 @@ object Classpaths { key: SettingKey[T], pkgTasks: Seq[TaskKey[HashedVirtualFileRef]] ): Initialize[Seq[T]] = - (forallIn(key, pkgTasks) zipWith forallIn(publishArtifact, pkgTasks))(_ zip _ collect { + (forallIn(key, pkgTasks).zipWith(forallIn(publishArtifact, pkgTasks)))(_ zip _ collect { case (a, true) => a }) def forallIn[T]( key: Scoped.ScopingSetting[SettingKey[T]], // should be just SettingKey[T] (mea culpa) - pkgTasks: Seq[TaskKey[_]], + pkgTasks: Seq[TaskKey[?]], ): Initialize[Seq[T]] = pkgTasks.map(pkg => (pkg.scope / pkg / key)).join @@ -3106,7 +3108,7 @@ object Classpaths { val sbtV = (pluginCrossBuild / sbtBinaryVersion).value sbtV != "1.0" && !sbtV.startsWith("0.") } - val jvmPublishSettings: Seq[Setting[_]] = Seq( + val jvmPublishSettings: Seq[Setting[?]] = Seq( artifacts := artifactDefs(defaultArtifactTasks).value, packagedArtifacts := Def .ifS(publishSbtPluginMavenStyle)(mavenArtifactsOfSbtPlugin)(packagedDefaultArtifacts) @@ -3197,7 +3199,7 @@ object Classpaths { pomFile } - val ivyPublishSettings: Seq[Setting[_]] = publishGlobalDefaults ++ Seq( + val ivyPublishSettings: Seq[Setting[?]] = publishGlobalDefaults ++ Seq( artifacts :== Nil, packagedArtifacts :== Map.empty, makePom := { @@ -3288,11 +3290,11 @@ object Classpaths { ) ) - val ivyBaseSettings: Seq[Setting[_]] = baseGlobalDefaults ++ sbtClassifiersTasks ++ Seq( + val ivyBaseSettings: Seq[Setting[?]] = baseGlobalDefaults ++ sbtClassifiersTasks ++ Seq( conflictWarning := conflictWarning.value.copy(label = Reference.display(thisProjectRef.value)), unmanagedBase := baseDirectory.value / "lib", normalizedName := Project.normalizeModuleID(name.value), - isSnapshot := (isSnapshot or version(_ endsWith "-SNAPSHOT")).value, + isSnapshot := (isSnapshot or version(_.endsWith("-SNAPSHOT"))).value, description := (description or name).value, organization := (organization or normalizedName).value, organizationName := (organizationName or organization).value, @@ -3327,7 +3329,7 @@ object Classpaths { } }, bootResolvers := { - (appConfiguration map bootRepositories).value + appConfiguration.map(bootRepositories).value }, fullResolvers := (Def.task { @@ -3643,7 +3645,7 @@ object Classpaths { IvyXml.generateIvyXmlSettings() ++ LMCoursier.publicationsSetting(Seq(Compile, Test).map(c => c -> CConfiguration(c.name))) - val jvmBaseSettings: Seq[Setting[_]] = Seq( + val jvmBaseSettings: Seq[Setting[?]] = Seq( libraryDependencies ++= autoLibraryDependency( autoScalaLibrary.value && scalaHome.value.isEmpty && managedScalaInstance.value, sbtPlugin.value, @@ -3731,7 +3733,7 @@ object Classpaths { private[sbt] def defaultProjectID: Initialize[ModuleID] = Def.setting { val p0 = ModuleID(organization.value, moduleName.value, version.value) .cross((projectID / crossVersion).value) - .artifacts(artifacts.value: _*) + .artifacts(artifacts.value*) val p1 = apiURL.value match { case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toExternalForm) case _ => p0 @@ -3832,43 +3834,46 @@ object Classpaths { }, dependencyResolution := dependencyResolutionTask.value, csrConfiguration := LMCoursier.updateSbtClassifierConfigurationTask.value, - (TaskGlobal / updateSbtClassifiers) := (Def.task { - val lm = dependencyResolution.value - val s = streams.value - val is = ivySbt.value - val mod = classifiersModule.value - val updateConfig0 = updateConfiguration.value - val updateConfig = updateConfig0 - .withMetadataDirectory(dependencyCacheDirectory.value) - .withArtifactFilter( - updateConfig0.artifactFilter.map(af => af.withInverted(!af.inverted)) - ) - val app = appConfiguration.value - val srcTypes = sourceArtifactTypes.value - val docTypes = docArtifactTypes.value - val log = s.log - val out = is.withIvy(log)(_.getSettings.getDefaultIvyUserDir) - val uwConfig = (update / unresolvedWarningConfiguration).value - withExcludes(out, mod.classifiers, lock(app)) { excludes => - // val noExplicitCheck = ivy.map(_.withCheckExplicit(false)) - LibraryManagement.transitiveScratch( - lm, - "sbt", - GetClassifiersConfiguration( - mod, - excludes.toVector, - updateConfig, - srcTypes.toVector, - docTypes.toVector - ), - uwConfig, - log - ) match { - case Left(_) => ??? - case Right(ur) => ur + (TaskGlobal / updateSbtClassifiers) := (Def + .task { + val lm = dependencyResolution.value + val s = streams.value + val is = ivySbt.value + val mod = classifiersModule.value + val updateConfig0 = updateConfiguration.value + val updateConfig = updateConfig0 + .withMetadataDirectory(dependencyCacheDirectory.value) + .withArtifactFilter( + updateConfig0.artifactFilter.map(af => af.withInverted(!af.inverted)) + ) + val app = appConfiguration.value + val srcTypes = sourceArtifactTypes.value + val docTypes = docArtifactTypes.value + val log = s.log + val out = is.withIvy(log)(_.getSettings.getDefaultIvyUserDir) + val uwConfig = (update / unresolvedWarningConfiguration).value + withExcludes(out, mod.classifiers, lock(app)) { excludes => + // val noExplicitCheck = ivy.map(_.withCheckExplicit(false)) + LibraryManagement.transitiveScratch( + lm, + "sbt", + GetClassifiersConfiguration( + mod, + excludes.toVector, + updateConfig, + srcTypes.toVector, + docTypes.toVector + ), + uwConfig, + log + ) match { + case Left(_) => ??? + case Right(ur) => ur + } } } - } tag (Tags.Update, Tags.Network)).value + .tag(Tags.Update, Tags.Network)) + .value ) ) ++ inTask(scalaCompilerBridgeScope)( @@ -3946,7 +3951,7 @@ object Classpaths { @deprecated("Use variant without delivery key", "1.1.1") def publishTask( config: TaskKey[PublishConfiguration], - deliverKey: TaskKey[_], + deliverKey: TaskKey[?], ): Initialize[Task[Unit]] = publishTask(config) @@ -4032,8 +4037,8 @@ object Classpaths { Option[ScalaInstance], File, File, - Seq[ScopedKey[_]], - ScopedKey[_], + Seq[ScopedKey[?]], + ScopedKey[?], Option[FiniteDuration], Boolean, ProjectRef, @@ -4190,26 +4195,26 @@ object Classpaths { val projRef = thisProjectRef.value val st = state.value val s = streams.value - val cacheStoreFactory = s.cacheStoreFactory sub updateCacheName.value + val cacheStoreFactory = s.cacheStoreFactory.sub(updateCacheName.value) import sbt.librarymanagement.LibraryManagementCodec._ def modulePositions: Map[ModuleID, SourcePosition] = try { - val extracted = (Project extract st) + val extracted = Project.extract(st) val sk = (projRef / Zero / Zero / libraryDependencies).scopedKey val empty = extracted.structure.data.set(sk.scope, sk.key, Nil) - val settings = extracted.structure.settings filter { (s: Setting[_]) => + val settings = extracted.structure.settings filter { (s: Setting[?]) => (s.key.key == libraryDependencies.key) && (s.key.scope.project == Select(projRef)) } Map(settings.asInstanceOf[Seq[Setting[Seq[ModuleID]]]].flatMap { s => s.init.evaluate(empty) map { _ -> s.pos } - }: _*) + }*) } catch { case NonFatal(_) => Map() } - val outCacheStore = cacheStoreFactory make "output_dsp" - val f = Tracked.inputChanged(cacheStoreFactory make "input_dsp") { + val outCacheStore = cacheStoreFactory.make("output_dsp") + val f = Tracked.inputChanged(cacheStoreFactory.make("input_dsp")) { (inChanged: Boolean, in: Seq[ModuleID]) => given NoPositionFormat: JsonFormat[NoPosition.type] = asSingleton(NoPosition) given LinePositionFormat: IsoLList.Aux[LinePosition, String :*: Int :*: LNil] = @@ -4503,7 +4508,10 @@ object Classpaths { ClasspathImpl.getClasspath(key, dep, conf, data) def defaultConfigurationTask(p: ResolvedReference, data: Settings[Scope]): Configuration = - flatten((p / defaultConfiguration) get data) getOrElse Configurations.Default + flatten( + (p / defaultConfiguration) + .get(data) + ).getOrElse(Configurations.Default) def flatten[T](o: Option[Option[T]]): Option[T] = o flatMap idFun @@ -4529,7 +4537,7 @@ object Classpaths { else Nil - def addUnmanagedLibrary: Seq[Setting[_]] = + def addUnmanagedLibrary: Seq[Setting[?]] = Seq((Compile / unmanagedJars) ++= unmanagedScalaLibrary.value) def unmanagedScalaLibrary: Initialize[Task[Seq[HashedVirtualFileRef]]] = @@ -4900,14 +4908,14 @@ trait BuildExtra extends BuildCommon with DefExtra { config: Configuration, mainClass: String, baseArguments: String* - ): Vector[Setting[_]] = { + ): Vector[Setting[?]] = { Vector( scoped := Def .input(_ => Def.spaceDelimited()) .flatMapTask { result => initScoped( scoped.scopedKey, - ClassLoaders.runner mapReferenced Project.mapScope(_.rescope(config)), + ClassLoaders.runner.mapReferenced(Project.mapScope(_.rescope(config))), ).zipWith(Def.task { ((config / fullClasspath).value, streams.value, fileConverter.value, result) }) { (rTask, t) => @@ -4928,11 +4936,11 @@ trait BuildExtra extends BuildCommon with DefExtra { config: Configuration, mainClass: String, arguments: String* - ): Vector[Setting[_]] = + ): Vector[Setting[?]] = Vector( scoped := initScoped( scoped.scopedKey, - ClassLoaders.runner mapReferenced Project.mapScope(_.rescope(config)), + ClassLoaders.runner.mapReferenced(Project.mapScope(_.rescope(config))), ).zipWith(Def.task { ((config / fullClasspath).value, streams.value, fileConverter.value) }) { case (rTask, t) => (t, rTask).mapN { case ((cp, s, converter), r) => @@ -4942,21 +4950,21 @@ trait BuildExtra extends BuildCommon with DefExtra { }.value ) ++ inTask(scoped)((config / forkOptions) := forkOptionsTask.value) - def initScoped[T](sk: ScopedKey[_], i: Initialize[T]): Initialize[T] = + def initScoped[T](sk: ScopedKey[?], i: Initialize[T]): Initialize[T] = initScope(fillTaskAxis(sk.scope, sk.key), i) def initScope[T](s: Scope, i: Initialize[T]): Initialize[T] = - i mapReferenced Project.mapScope(Scope.replaceThis(s)) + i.mapReferenced(Project.mapScope(Scope.replaceThis(s))) /** * Disables post-compilation hook for determining tests for tab-completion (such as for 'test-only'). * This is useful for reducing Test/compile time when not running test. */ - def noTestCompletion(config: Configuration = Test): Setting[_] = + def noTestCompletion(config: Configuration = Test): Setting[?] = inConfig(config)(Seq(definedTests := detectTests.value)).head - def filterKeys(ss: Seq[Setting[_]], transitive: Boolean = false)( - f: ScopedKey[_] => Boolean - ): Seq[Setting[_]] = + def filterKeys(ss: Seq[Setting[?]], transitive: Boolean = false)( + f: ScopedKey[?] => Boolean + ): Seq[Setting[?]] = ss filter (s => f(s.key) && (!transitive || s.dependencies.forall(f))) implicit def sbtStateToUpperStateOps(s: State): UpperStateOps = @@ -4989,7 +4997,7 @@ trait BuildCommon { extension (s: Seq[HashedVirtualFileRef]) /** Converts the `Seq[HashedVirtualFileRef]` to a Classpath, which is an alias for `Seq[Attributed[HashedVirtualFileRef]]`. */ - def classpath: Classpath = Attributed blankSeq s + def classpath: Classpath = Attributed.blankSeq(s) def overrideConfigs(cs: Configuration*)( configurations: Seq[Configuration] @@ -5006,10 +5014,10 @@ trait BuildCommon { } // these are intended for use in in put tasks for creating parsers - def getFromContext[T](task: TaskKey[T], context: ScopedKey[_], s: State): Option[T] = + def getFromContext[T](task: TaskKey[T], context: ScopedKey[?], s: State): Option[T] = SessionVar.get(SessionVar.resolveContext(task.scopedKey, context.scope, s), s) - def loadFromContext[T](task: TaskKey[T], context: ScopedKey[_], s: State)(implicit + def loadFromContext[T](task: TaskKey[T], context: ScopedKey[?], s: State)(implicit f: JsonFormat[T] ): Option[T] = SessionVar.load(SessionVar.resolveContext(task.scopedKey, context.scope, s), s) @@ -5018,7 +5026,7 @@ trait BuildCommon { def loadForParser[P, T](task: TaskKey[T])( f: (State, Option[T]) => Parser[P] )(implicit format: JsonFormat[T]): Initialize[State => Parser[P]] = - loadForParserI(task)(Def value f)(format) + loadForParserI(task)(Def.value(f))(format) def loadForParserI[P, T](task: TaskKey[T])( init: Initialize[(State, Option[T]) => Parser[P]] )(implicit format: JsonFormat[T]): Initialize[State => Parser[P]] = @@ -5029,7 +5037,7 @@ trait BuildCommon { def getForParser[P, T]( task: TaskKey[T] )(init: (State, Option[T]) => Parser[P]): Initialize[State => Parser[P]] = - getForParserI(task)(Def value init) + getForParserI(task)(Def.value(init)) def getForParserI[P, T]( task: TaskKey[T] )(init: Initialize[(State, Option[T]) => Parser[P]]): Initialize[State => Parser[P]] = diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index bb9255160..326736b90 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -333,7 +333,7 @@ object EvaluateTask { ): T = (extracted.currentRef / key).get(structure.data).getOrElse(default) - def injectSettings: Seq[Setting[_]] = Seq( + def injectSettings: Seq[Setting[?]] = Seq( Global / state ::= dummyState, Global / streamsManager ::= Def.dummyStreamsManager, Global / executionRoots ::= dummyRoots, @@ -392,12 +392,12 @@ object EvaluateTask { } } - def logIncResult(result: Result[_], state: State, streams: Streams) = result match { + def logIncResult(result: Result[?], state: State, streams: Streams) = result match { case Result.Inc(i) => logIncomplete(i, state, streams); case _ => () } def logIncomplete(result: Incomplete, state: State, streams: Streams): Unit = { - val all = Incomplete linearize result + val all = Incomplete.linearize(result) val keyed = all collect { case Incomplete(Some(key: ScopedKey[_]), _, msg, _, ex) => (key, msg, ex) @@ -426,10 +426,10 @@ object EvaluateTask { private def contextDisplay(state: State, highlight: Boolean) = Project.showContextKey(state, if (highlight) Some(RED) else None) - def suppressedMessage(key: ScopedKey[_])(implicit display: Show[ScopedKey[_]]): String = + def suppressedMessage(key: ScopedKey[?])(implicit display: Show[ScopedKey[?]]): String = "Stack trace suppressed. Run 'last %s' for the full log.".format(display.show(key)) - def getStreams(key: ScopedKey[_], streams: Streams): TaskStreams = + def getStreams(key: ScopedKey[?], streams: Streams): TaskStreams = streams(ScopedKey(Project.fillTaskAxis(key).scope, Keys.streams.key)) def withStreams[T](structure: BuildStructure, state: State)(f: Streams => T): T = { @@ -456,7 +456,7 @@ object EvaluateTask { def nodeView( state: State, streams: Streams, - roots: Seq[ScopedKey[_]], + roots: Seq[ScopedKey[?]], dummies: DummyTaskMap = DummyTaskMap(Nil) ): NodeView = Transform( @@ -568,7 +568,7 @@ object EvaluateTask { state: State, streams: Streams ): Unit = - for (referenced <- (Global / Previous.references) get Project.structure(state).data) + for (referenced <- (Global / Previous.references).get(Project.structure(state).data)) Previous.complete(referenced, results, streams) def applyResults[T]( @@ -582,7 +582,7 @@ object EvaluateTask { Function.chain( results.toTypedSeq flatMap { case results.TPair(_, Result.Value(KeyValue(_, st: StateTransform))) => Some(st.transform) - case results.TPair(Task(info, _), Result.Value(v)) => info.post(v) get transformState + case results.TPair(Task(info, _), Result.Value(v)) => info.post(v).get(transformState) case _ => Nil } ) @@ -647,7 +647,7 @@ object EvaluateTask { } // if the return type Seq[Setting[_]] is not explicitly given, scalac hangs - val injectStreams: ScopedKey[_] => Seq[Setting[_]] = scoped => + val injectStreams: ScopedKey[?] => Seq[Setting[?]] = scoped => if (scoped.key == streams.key) { Seq(scoped.scope / streams := { (streamsManager.map { mgr => diff --git a/main/src/main/scala/sbt/ExecuteProgress2.scala b/main/src/main/scala/sbt/ExecuteProgress2.scala index fff7c95e5..b30fe4972 100644 --- a/main/src/main/scala/sbt/ExecuteProgress2.scala +++ b/main/src/main/scala/sbt/ExecuteProgress2.scala @@ -45,12 +45,12 @@ class ExecuteProgressAdapter(ep: ExecuteProgress) extends ExecuteProgress2 { override def afterCommand(cmd: String, result: Either[Throwable, State]): Unit = {} override def initial(): Unit = ep.initial() override def afterRegistered( - task: TaskId[_], - allDeps: Iterable[TaskId[_]], - pendingDeps: Iterable[TaskId[_]] + task: TaskId[?], + allDeps: Iterable[TaskId[?]], + pendingDeps: Iterable[TaskId[?]] ): Unit = ep.afterRegistered(task, allDeps, pendingDeps) - override def afterReady(task: TaskId[_]): Unit = ep.afterReady(task) - override def beforeWork(task: TaskId[_]): Unit = ep.beforeWork(task) + override def afterReady(task: TaskId[?]): Unit = ep.afterReady(task) + override def beforeWork(task: TaskId[?]): Unit = ep.beforeWork(task) override def afterWork[A](task: TaskId[A], result: Either[TaskId[A], Result[A]]): Unit = ep.afterWork(task, result) override def afterCompleted[A](task: TaskId[A], result: Result[A]): Unit = @@ -68,12 +68,12 @@ object ExecuteProgress2 { xs.foreach(_.afterCommand(cmd, result)) override def initial(): Unit = xs.foreach(_.initial()) override def afterRegistered( - task: TaskId[_], - allDeps: Iterable[TaskId[_]], - pendingDeps: Iterable[TaskId[_]] + task: TaskId[?], + allDeps: Iterable[TaskId[?]], + pendingDeps: Iterable[TaskId[?]] ): Unit = xs.foreach(_.afterRegistered(task, allDeps, pendingDeps)) - override def afterReady(task: TaskId[_]): Unit = xs.foreach(_.afterReady(task)) - override def beforeWork(task: TaskId[_]): Unit = xs.foreach(_.beforeWork(task)) + override def afterReady(task: TaskId[?]): Unit = xs.foreach(_.afterReady(task)) + override def beforeWork(task: TaskId[?]): Unit = xs.foreach(_.beforeWork(task)) override def afterWork[A](task: TaskId[A], result: Either[TaskId[A], Result[A]]): Unit = xs.foreach(_.afterWork(task, result)) override def afterCompleted[A](task: TaskId[A], result: Result[A]): Unit = diff --git a/main/src/main/scala/sbt/Extracted.scala b/main/src/main/scala/sbt/Extracted.scala index 72dd0abb6..4f3adc174 100644 --- a/main/src/main/scala/sbt/Extracted.scala +++ b/main/src/main/scala/sbt/Extracted.scala @@ -23,7 +23,7 @@ final case class Extracted( structure: BuildStructure, session: SessionSettings, currentRef: ProjectRef -)(implicit val showKey: Show[ScopedKey[_]]) { +)(implicit val showKey: Show[ScopedKey[?]]) { def rootProject = structure.rootProject lazy val currentUnit = structure units currentRef.build lazy val currentProject = currentUnit defined currentRef.project @@ -113,16 +113,16 @@ final case class Extracted( show = Aggregation.defaultShow(state, false), ) - private def resolve[K <: Scoped.ScopingSetting[K] with Scoped](key: K): K = + private def resolve[K <: Scoped.ScopingSetting[K] & Scoped](key: K): K = Scope.resolveScope(GlobalScope, currentRef.build, rootProject)(key.scope) / key - private def getOrError[T](scope: Scope, key: AttributeKey[_], value: Option[T])(implicit - display: Show[ScopedKey[_]] + private def getOrError[T](scope: Scope, key: AttributeKey[?], value: Option[T])(implicit + display: Show[ScopedKey[?]] ): T = value getOrElse sys.error(display.show(ScopedKey(scope, key)) + " is undefined.") private def getOrError[T](scope: Scope, key: AttributeKey[T])(implicit - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): T = getOrError(scope, key, structure.data.get(scope, key))(display) @@ -130,24 +130,24 @@ final case class Extracted( "This discards session settings. Migrate to appendWithSession or appendWithoutSession.", "1.2.0" ) - def append(settings: Seq[Setting[_]], state: State): State = + def append(settings: Seq[Setting[?]], state: State): State = appendWithoutSession(settings, state) /** Appends the given settings to all the build state settings, including session settings. */ - def appendWithSession(settings: Seq[Setting[_]], state: State): State = + def appendWithSession(settings: Seq[Setting[?]], state: State): State = appendImpl(settings, state, session.mergeSettings) /** * Appends the given settings to the original build state settings, discarding any settings * appended to the session in the process. */ - def appendWithoutSession(settings: Seq[Setting[_]], state: State): State = + def appendWithoutSession(settings: Seq[Setting[?]], state: State): State = appendImpl(settings, state, session.original) private def appendImpl( - settings: Seq[Setting[_]], + settings: Seq[Setting[?]], state: State, - sessionSettings: Seq[Setting[_]], + sessionSettings: Seq[Setting[?]], ): State = { val appendSettings = Load.transformSettings(Load.projectScope(currentRef), currentRef.build, rootProject, settings) diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 429794e84..93ed52e72 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -62,7 +62,7 @@ object Keys { val showTiming = settingKey[Boolean]("If true, the command success message includes the completion time.").withRank(CSetting) val timingFormat = settingKey[java.text.DateFormat]("The format used for displaying the completion time.").withRank(CSetting) @deprecated("", "1.4.0") - val extraLoggers = settingKey[ScopedKey[_] => Seq[XAppender]]("A function that provides additional loggers for a given setting.").withRank(DSetting) + val extraLoggers = settingKey[ScopedKey[?] => Seq[XAppender]]("A function that provides additional loggers for a given setting.").withRank(DSetting) val extraAppenders = settingKey[AppenderSupplier]("A function that provides additional loggers for a given setting.").withRank(DSetting) val useLog4J = settingKey[Boolean]("Toggles whether or not to use log4j for sbt internal loggers.").withRank(Invisible) val logManager = settingKey[LogManager]("The log manager, which creates Loggers for different contexts.").withRank(DSetting) @@ -644,7 +644,7 @@ object Keys { @cacheLevel(include = Array.empty) val streams = taskKey[TaskStreams]("Provides streams for logging and persisting data.").withRank(DTask) val taskDefinitionKey = Def.taskDefinitionKey - val (executionRoots, dummyRoots) = Def.dummy[Seq[ScopedKey[_]]]("executionRoots", "The list of root tasks for this task execution. Roots are the top-level tasks that were directly requested to be run.") + val (executionRoots, dummyRoots) = Def.dummy[Seq[ScopedKey[?]]]("executionRoots", "The list of root tasks for this task execution. Roots are the top-level tasks that were directly requested to be run.") val state = Def.stateKey val streamsManager = Def.streamsManagerKey // wrapper to work around SI-2915 @@ -670,8 +670,8 @@ object Keys { val lintUnused = inputKey[Unit]("Check for keys unused by other settings and tasks.") val lintIncludeFilter = settingKey[String => Boolean]("Filters key names that should be included in the lint check.") val lintExcludeFilter = settingKey[String => Boolean]("Filters key names that should be excluded in the lint check.") - val excludeLintKeys = settingKey[Set[Def.KeyedInitialize[_]]]("Keys excluded from lintUnused task") - val includeLintKeys = settingKey[Set[Def.KeyedInitialize[_]]]("Task keys that are included into lintUnused task") + val excludeLintKeys = settingKey[Set[Def.KeyedInitialize[?]]]("Keys excluded from lintUnused task") + val includeLintKeys = settingKey[Set[Def.KeyedInitialize[?]]]("Task keys that are included into lintUnused task") val lintUnusedKeysOnLoad = settingKey[Boolean]("Toggles whether or not to check for unused keys during startup") val useScalaReplJLine = settingKey[Boolean]("Toggles whether or not to use sbt's forked jline in the scala repl. Enabling this flag may break the thin client in the scala console.").withRank(KeyRanks.Invisible) @@ -692,8 +692,8 @@ object Keys { val triggeredBy = Def.triggeredBy val runBefore = Def.runBefore - type Streams = std.Streams[ScopedKey[_]] - type TaskStreams = std.TaskStreams[ScopedKey[_]] + type Streams = std.Streams[ScopedKey[?]] + type TaskStreams = std.TaskStreams[ScopedKey[?]] } // format: on diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 7393a55b6..dc6d97664 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -464,7 +464,7 @@ object BuiltinCommands { command: String, preamble: String, cutoff: Int, - keep: AttributeKey[_] => Boolean + keep: AttributeKey[?] => Boolean ): Command = Command(command, settingsBrief(command), settingsDetailed(command))(showSettingParser(keep)) { case (s: State, (verbosity: Int, selected: Option[String])) => @@ -477,10 +477,10 @@ object BuiltinCommands { s } def showSettingParser( - keepKeys: AttributeKey[_] => Boolean + keepKeys: AttributeKey[?] => Boolean )(s: State): Parser[(Int, Option[String])] = verbosityParser ~ selectedParser(s, keepKeys).? - def selectedParser(s: State, keepKeys: AttributeKey[_] => Boolean): Parser[String] = + def selectedParser(s: State, keepKeys: AttributeKey[?] => Boolean): Parser[String] = singleArgument(allTaskAndSettingKeys(s).withFilter(keepKeys).map(_.label).toSet) def verbosityParser: Parser[Int] = success(1) | ((Space ~ "-") ~> ( @@ -488,15 +488,15 @@ object BuiltinCommands { ("V" ^^^ Int.MaxValue) )) - def taskDetail(keys: Seq[AttributeKey[_]], firstOnly: Boolean): Seq[(String, String)] = + def taskDetail(keys: Seq[AttributeKey[?]], firstOnly: Boolean): Seq[(String, String)] = sortByLabel(withDescription(keys)) flatMap { t => taskStrings(t, firstOnly) } - def taskDetail(keys: Seq[AttributeKey[_]]): Seq[(String, String)] = + def taskDetail(keys: Seq[AttributeKey[?]]): Seq[(String, String)] = taskDetail(keys, false) - def allTaskAndSettingKeys(s: State): Seq[AttributeKey[_]] = { + def allTaskAndSettingKeys(s: State): Seq[AttributeKey[?]] = { val extracted = Project.extract(s) import extracted._ val index = structure.index @@ -507,7 +507,7 @@ object BuiltinCommands { try Some(index.keyMap(key)) catch { case NonFatal(ex) => - s.log debug ex.getMessage + s.log.debug(ex.getMessage) None } } @@ -515,19 +515,19 @@ object BuiltinCommands { .distinct } - def sortByLabel(keys: Seq[AttributeKey[_]]): Seq[AttributeKey[_]] = keys.sortBy(_.label) - def sortByRank(keys: Seq[AttributeKey[_]]): Seq[AttributeKey[_]] = keys.sortBy(_.rank) - def withDescription(keys: Seq[AttributeKey[_]]): Seq[AttributeKey[_]] = + def sortByLabel(keys: Seq[AttributeKey[?]]): Seq[AttributeKey[?]] = keys.sortBy(_.label) + def sortByRank(keys: Seq[AttributeKey[?]]): Seq[AttributeKey[?]] = keys.sortBy(_.rank) + def withDescription(keys: Seq[AttributeKey[?]]): Seq[AttributeKey[?]] = keys.filter(_.description.isDefined) - def topNRanked(n: Int) = (keys: Seq[AttributeKey[_]]) => sortByRank(keys).take(n) + def topNRanked(n: Int) = (keys: Seq[AttributeKey[?]]) => sortByRank(keys).take(n) def highPass(rankCutoff: Int) = - (keys: Seq[AttributeKey[_]]) => sortByRank(keys).takeWhile(_.rank <= rankCutoff) + (keys: Seq[AttributeKey[?]]) => sortByRank(keys).takeWhile(_.rank <= rankCutoff) def tasksHelp( s: State, - filter: Seq[AttributeKey[_]] => Seq[AttributeKey[_]], + filter: Seq[AttributeKey[?]] => Seq[AttributeKey[?]], arg: Option[String] ): String = { val commandAndDescription = taskDetail(filter(allTaskAndSettingKeys(s)), true) @@ -537,12 +537,12 @@ object BuiltinCommands { } } - def taskStrings(key: AttributeKey[_], firstOnly: Boolean): Option[(String, String)] = + def taskStrings(key: AttributeKey[?], firstOnly: Boolean): Option[(String, String)] = key.description map { d => if (firstOnly) (key.label, d.split("\r?\n")(0)) else (key.label, d) } - def taskStrings(key: AttributeKey[_]): Option[(String, String)] = taskStrings(key, false) + def taskStrings(key: AttributeKey[?]): Option[(String, String)] = taskStrings(key, false) def defaults = Command.command(DefaultsCommand) { s => s.copy(definedCommands = DefaultCommands) @@ -592,7 +592,7 @@ object BuiltinCommands { } def set: Command = Command(SetCommand, setBrief, setDetailed)(setParser) { case (s, (all, arg)) => - val extracted = Project extract s + val extracted = Project.extract(s) import extracted._ val dslVals = extracted.currentUnit.unit.definitions.dslDefinitions // TODO - This is possibly inefficient (or stupid). We should try to only attach the @@ -619,14 +619,14 @@ object BuiltinCommands { def setThis( s: State, extracted: Extracted, - settings: Seq[Def.Setting[_]], + settings: Seq[Def.Setting[?]], arg: String ): SetResult = setThis(extracted, settings, arg) def setThis( extracted: Extracted, - settings: Seq[Def.Setting[_]], + settings: Seq[Def.Setting[?]], arg: String ): SetResult = SettingCompletions.setThis(extracted, settings, arg) @@ -660,7 +660,7 @@ object BuiltinCommands { } } - def extractLast(s: State): (BuildStructure, Select[ProjectRef], Show[Def.ScopedKey[_]]) = { + def extractLast(s: State): (BuildStructure, Select[ProjectRef], Show[Def.ScopedKey[?]]) = { val ext = Project.extract(s) (ext.structure, Select(ext.currentRef), ext.showKey) } @@ -686,7 +686,7 @@ object BuiltinCommands { Act.requireSession(s, token(Space) ~> exportParser0(s)) private[sbt] def exportParser0(s: State): Parser[() => State] = { - val extracted = Project extract s + val extracted = Project.extract(s) import extracted.{ showKey, structure } val keysParser = token(flag("--last" <~ Space)) ~ Act.aggregatedKeyParser(extracted) val show = Aggregation.ShowConfig( @@ -823,7 +823,7 @@ object BuiltinCommands { } def showProjects(s: State): Unit = { - val extracted = Project extract s + val extracted = Project.extract(s) import extracted._ listBuild(currentRef.build, structure.units(currentRef.build), true, currentRef.project, s.log) for ((uri, build) <- structure.units if currentRef.build != uri) @@ -1012,7 +1012,7 @@ object BuiltinCommands { def clearCaches: Command = { val help = Help.more(ClearCaches, ClearCachesDetailed) val f: State => State = - registerCompilerCache _ andThen (_.initializeClassLoaderCache) andThen addCacheStoreFactoryFactory + registerCompilerCache andThen (_.initializeClassLoaderCache) andThen addCacheStoreFactoryFactory Command.command(ClearCaches, help)(f) } @@ -1068,7 +1068,7 @@ object BuiltinCommands { import sbt.internal.ConsolePromptEvent val exchange = StandardMain.exchange val welcomeState = displayWelcomeBanner(s0) - val s1 = exchange run welcomeState + val s1 = exchange.run(welcomeState) /* * It is possible for sbt processes to leak if two are started simultaneously * by a remote client and only one is able to start a server. This seems to @@ -1078,7 +1078,7 @@ object BuiltinCommands { Exec(Shutdown, None) +: s1 } else { if (ITerminal.console.prompt == Prompt.Batch) ITerminal.console.setPrompt(Prompt.Pending) - exchange prompt ConsolePromptEvent(s0) + exchange.prompt(ConsolePromptEvent(s0)) val minGCInterval = Project .extract(s1) .getOpt(Keys.minForcegcInterval) @@ -1127,10 +1127,10 @@ object BuiltinCommands { if (isSbtBuild(baseDir)) { val line = s"sbt.version=$sbtVersion" IO.writeLines(buildProps, line :: buildPropsLines) - state.log info s"Updated file $buildProps: set sbt.version to $sbtVersion" - } else state.log warn warnMsg + state.log.info(s"Updated file $buildProps: set sbt.version to $sbtVersion") + } else state.log.warn(warnMsg) } catch { - case _: IOException => state.log warn warnMsg + case _: IOException => state.log.warn(warnMsg) } } } @@ -1174,9 +1174,13 @@ object BuiltinCommands { state.remainingCommands exists (_.commandLine == StartServer) private def notifyUsersAboutShell(state: State): Unit = { - val suppress = Project extract state getOpt Keys.suppressSbtShellNotification getOrElse false + val suppress = + Project + .extract(state) + .getOpt(Keys.suppressSbtShellNotification) + .getOrElse(false) if (!suppress && intendsToInvokeCompile(state) && !hasRebooted(state)) - state.log info "Executing in batch mode. For better performance use sbt's shell" + state.log.info("Executing in batch mode. For better performance use sbt's shell") } private def NotifyUsersAboutShell = "notifyUsersAboutShell" diff --git a/main/src/main/scala/sbt/MainLoop.scala b/main/src/main/scala/sbt/MainLoop.scala index 12f6a5279..b2fe1b016 100644 --- a/main/src/main/scala/sbt/MainLoop.scala +++ b/main/src/main/scala/sbt/MainLoop.scala @@ -362,7 +362,7 @@ object MainLoop { case _: xsbti.Reboot => ExitCode.Success case x => val clazz = if (x eq null) "" else " (class: " + x.getClass + ")" - state.log debug s"Unknown main result: $x$clazz" + state.log.debug(s"Unknown main result: $x$clazz") ExitCode.Unknown } } diff --git a/main/src/main/scala/sbt/Opts.scala b/main/src/main/scala/sbt/Opts.scala index 57b0fc3d6..f6deb3a25 100644 --- a/main/src/main/scala/sbt/Opts.scala +++ b/main/src/main/scala/sbt/Opts.scala @@ -86,13 +86,13 @@ object DefaultOptions { if (plugin && snapshot) Vector(resolver.sbtSnapshots, resolver.sbtIvySnapshots) else Vector.empty } - def addResolvers: Setting[_] = Keys.resolvers ++= { resolvers(Keys.isSnapshot.value) } - def addPluginResolvers: Setting[_] = + def addResolvers: Setting[?] = Keys.resolvers ++= { resolvers(Keys.isSnapshot.value) } + def addPluginResolvers: Setting[?] = Keys.resolvers ++= pluginResolvers(Keys.sbtPlugin.value, Keys.isSnapshot.value) def credentials(state: State): Credentials = Credentials(getGlobalSettingsDirectory(state, getGlobalBase(state)) / ".credentials") - def addCredentials: Setting[_] = Keys.credentials += { credentials(Keys.state.value) } + def addCredentials: Setting[?] = Keys.credentials += { credentials(Keys.state.value) } def shellPrompt(version: String): State => String = s => @@ -101,5 +101,5 @@ object DefaultOptions { Project.extract(s).currentProject.id, version ) - def setupShellPrompt: Setting[_] = Keys.shellPrompt := { shellPrompt(Keys.version.value) } + def setupShellPrompt: Setting[?] = Keys.shellPrompt := { shellPrompt(Keys.version.value) } } diff --git a/main/src/main/scala/sbt/PluginCross.scala b/main/src/main/scala/sbt/PluginCross.scala index 773d57bc3..ff165920b 100644 --- a/main/src/main/scala/sbt/PluginCross.scala +++ b/main/src/main/scala/sbt/PluginCross.scala @@ -36,7 +36,7 @@ private[sbt] object PluginCross { } } - def crossExclude(s: Def.Setting[_]): Boolean = + def crossExclude(s: Def.Setting[?]): Boolean = s.key match { case ScopedKey(Scope(_, _, pluginCrossBuild.key, _), sbtVersion.key) => true case _ => false @@ -71,7 +71,10 @@ private[sbt] object PluginCross { def crossVersions(state: State): List[String] = { val x = Project.extract(state) import x._ - ((currentRef / crossSbtVersions) get structure.data getOrElse Nil).toList + (currentRef / crossSbtVersions) + .get(structure.data) + .getOrElse(Nil) + .toList } Command.arb(requireSession(crossParser), pluginCrossHelp) { case (state, command) => val x = Project.extract(state) diff --git a/main/src/main/scala/sbt/ProjectExtra.scala b/main/src/main/scala/sbt/ProjectExtra.scala index f8d62ec3e..f512f845a 100755 --- a/main/src/main/scala/sbt/ProjectExtra.scala +++ b/main/src/main/scala/sbt/ProjectExtra.scala @@ -154,14 +154,14 @@ object ProjectExtra extends ProjectExtra: trait ProjectExtra extends Scoped.Syntax: import ProjectExtra.projectReturnKey - def inConfig(conf: Configuration)(ss: Seq[Setting[_]]): Seq[Setting[_]] = + def inConfig(conf: Configuration)(ss: Seq[Setting[?]]): Seq[Setting[?]] = Project.inScope(ThisScope.copy(config = Select(conf)))((Keys.configuration :== conf) +: ss) extension (self: Project) /** Adds configurations to this project. Added configurations replace existing configurations with the same name. */ def overrideConfigs(cs: Configuration*): Project = self.copy( - configurations = Defaults.overrideConfigs(cs: _*)(self.configurations), + configurations = Defaults.overrideConfigs(cs*)(self.configurations), ) /** @@ -170,7 +170,7 @@ trait ProjectExtra extends Scoped.Syntax: */ private[sbt] def prefixConfigs(cs: Configuration*): Project = self.copy( - configurations = Defaults.overrideConfigs(self.configurations: _*)(cs), + configurations = Defaults.overrideConfigs(self.configurations*)(cs), ) extension (m: Project.type) @@ -195,10 +195,10 @@ trait ProjectExtra extends Scoped.Syntax: } */ - def showContextKey(state: State): Show[ScopedKey[_]] = + def showContextKey(state: State): Show[ScopedKey[?]] = showContextKey(state, None) - def showContextKey(state: State, keyNameColor: Option[String]): Show[ScopedKey[_]] = + def showContextKey(state: State, keyNameColor: Option[String]): Show[ScopedKey[?]] = if (isProjectLoaded(state)) showContextKey2(session(state), keyNameColor) else Def.showFullKey @@ -213,13 +213,13 @@ trait ProjectExtra extends Scoped.Syntax: def showContextKey2( session: SessionSettings, keyNameColor: Option[String] = None - ): Show[ScopedKey[_]] = + ): Show[ScopedKey[?]] = Def.showRelativeKey2(session.current, keyNameColor) def showLoadingKey( loaded: LoadedBuild, keyNameColor: Option[String] = None - ): Show[ScopedKey[_]] = + ): Show[ScopedKey[?]] = Def.showRelativeKey2( ProjectRef(loaded.root, loaded.units(loaded.root).rootProjects.head), keyNameColor @@ -258,7 +258,7 @@ trait ProjectExtra extends Scoped.Syntax: (units get ref.build).flatMap(_.defined get ref.project) def runUnloadHooks(s: State): State = - val previousOnUnload = orIdentity(s get Keys.onUnload.key) + val previousOnUnload = orIdentity(s.get(Keys.onUnload.key)) previousOnUnload(s.runExitHooks()) def setProject(session: SessionSettings, structure: BuildStructure, s: State): State = @@ -289,7 +289,7 @@ trait ProjectExtra extends Scoped.Syntax: opt.getOrElse(identity) def getHook[A](key: SettingKey[A => A], data: Settings[Scope]): A => A = - orIdentity((Global / key) get data) + orIdentity((Global / key).get(data)) def getHooks(data: Settings[Scope]): (State => State, State => State) = (getHook(Keys.onLoad, data), getHook(Keys.onUnload, data)) @@ -300,9 +300,9 @@ trait ProjectExtra extends Scoped.Syntax: val structure = Project.structure(s) val ref = Project.current(s) Load.getProject(structure.units, ref.build, ref.project) - val msg = (ref / Keys.onLoadMessage) get structure.data getOrElse "" + val msg = (ref / Keys.onLoadMessage).get(structure.data).getOrElse("") if (!msg.isEmpty) s.log.info(msg) - def get[T](k: SettingKey[T]): Option[T] = (ref / k) get structure.data + def get[T](k: SettingKey[T]): Option[T] = (ref / k).get(structure.data) def commandsIn(axis: ResolvedReference) = (axis / commands).get(structure.data).toList val allCommands = commandsIn(ref) ++ commandsIn( @@ -311,7 +311,7 @@ trait ProjectExtra extends Scoped.Syntax: val history = get(historyPath).flatMap(identity) val prompt = get(shellPrompt) val newPrompt = get(colorShellPrompt) - val trs = ((Global / templateResolverInfos) get structure.data).toList.flatten + val trs = ((Global / templateResolverInfos).get(structure.data)).toList.flatten val startSvr: Option[Boolean] = get(autoStartServer) val host: Option[String] = get(serverHost) val port: Option[Int] = get(serverPort) @@ -324,7 +324,7 @@ trait ProjectExtra extends Scoped.Syntax: val caches: Option[Seq[ActionCacheStore]] = get(cacheStores) val rod: Option[NioPath] = get(rootOutputDirectory) val fileConverter: Option[FileConverter] = get(Keys.fileConverter) - val commandDefs = allCommands.distinct.flatten[Command].map(_ tag (projectCommand, true)) + val commandDefs = allCommands.distinct.flatten[Command].map(_.tag(projectCommand, true)) val newDefinedCommands = commandDefs ++ BasicCommands.removeTagged( s.definedCommands, projectCommand @@ -361,27 +361,27 @@ trait ProjectExtra extends Scoped.Syntax: def setCond[T](key: AttributeKey[T], vopt: Option[T], attributes: AttributeMap): AttributeMap = attributes.setCond(key, vopt) - private[sbt] def equalKeys(a: ScopedKey[_], b: ScopedKey[_], mask: ScopeMask): Boolean = + private[sbt] def equalKeys(a: ScopedKey[?], b: ScopedKey[?], mask: ScopeMask): Boolean = a.key == b.key && Scope.equal(a.scope, b.scope, mask) def delegates( structure: BuildStructure, scope: Scope, - key: AttributeKey[_] - ): Seq[ScopedKey[_]] = + key: AttributeKey[?] + ): Seq[ScopedKey[?]] = structure.delegates(scope).map(d => ScopedKey(d, key)) private[sbt] def scopedKeyData( structure: BuildStructure, scope: Scope, - key: AttributeKey[_] - ): Option[ScopedKeyData[_]] = + key: AttributeKey[?] + ): Option[ScopedKeyData[?]] = structure.data.get(scope, key) map { v => ScopedKeyData(ScopedKey(scope, key), v) } - def details(structure: BuildStructure, actual: Boolean, scope: Scope, key: AttributeKey[_])( - using display: Show[ScopedKey[_]] + def details(structure: BuildStructure, actual: Boolean, scope: Scope, key: AttributeKey[?])( + using display: Show[ScopedKey[?]] ): String = { val scoped = ScopedKey(scope, key) @@ -413,7 +413,7 @@ trait ProjectExtra extends Scoped.Syntax: val cMap = Def.flattenLocals(comp) val related = cMap.keys.filter(k => k.key == key && k.scope != scope) - def derivedDependencies(c: ScopedKey[_]): List[ScopedKey[_]] = + def derivedDependencies(c: ScopedKey[?]): List[ScopedKey[?]] = comp .get(c) .map(_.settings.flatMap(s => if (s.isDerived) s.dependencies else Nil)) @@ -423,7 +423,7 @@ trait ProjectExtra extends Scoped.Syntax: val depends = cMap.get(scoped) match { case Some(c) => c.dependencies.toSet; case None => Set.empty } - val derivedDepends: Set[ScopedKey[_]] = derivedDependencies(definingScoped).toSet + val derivedDepends: Set[ScopedKey[?]] = derivedDependencies(definingScoped).toSet val reverse = Project.reverseDependencies(cMap, scoped) val derivedReverse = @@ -432,20 +432,20 @@ trait ProjectExtra extends Scoped.Syntax: def printDepScopes( baseLabel: String, derivedLabel: String, - scopes: Iterable[ScopedKey[_]], - derived: Set[ScopedKey[_]] + scopes: Iterable[ScopedKey[?]], + derived: Set[ScopedKey[?]] ): String = { val label = s"$baseLabel${if (derived.isEmpty) "" else s" (D=$derivedLabel)"}" - val prefix: ScopedKey[_] => String = + val prefix: ScopedKey[?] => String = if (derived.isEmpty) const("") else sk => if (derived(sk)) "D " else " " printScopes(label, scopes, prefix = prefix) } def printScopes( label: String, - scopes: Iterable[ScopedKey[_]], + scopes: Iterable[ScopedKey[?]], max: Int = Int.MaxValue, - prefix: ScopedKey[_] => String = const("") + prefix: ScopedKey[?] => String = const("") ) = if (scopes.isEmpty) "" else { @@ -464,8 +464,8 @@ trait ProjectExtra extends Scoped.Syntax: printScopes("Related", related, 10) } - def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_])(using - display: Show[ScopedKey[_]] + def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[?])(using + display: Show[ScopedKey[?]] ): SettingGraph = SettingGraph(structure, basedir, scoped, 0) @@ -488,54 +488,54 @@ trait ProjectExtra extends Scoped.Syntax: */ def relation(structure: BuildStructure, actual: Boolean)(using - display: Show[ScopedKey[_]] - ): Relation[ScopedKey[_], ScopedKey[_]] = + display: Show[ScopedKey[?]] + ): Relation[ScopedKey[?], ScopedKey[?]] = relation(structure.settings, actual)(using structure.delegates, structure.scopeLocal, display, ) - private[sbt] def relation(settings: Seq[Def.Setting[_]], actual: Boolean)(using + private[sbt] def relation(settings: Seq[Def.Setting[?]], actual: Boolean)(using delegates: Scope => Seq[Scope], scopeLocal: Def.ScopeLocal, - display: Show[ScopedKey[_]] - ): Relation[ScopedKey[_], ScopedKey[_]] = + display: Show[ScopedKey[?]] + ): Relation[ScopedKey[?], ScopedKey[?]] = val cMap = Def.flattenLocals(Def.compiled(settings, actual)) - val emptyRelation = Relation.empty[ScopedKey[_], ScopedKey[_]] + val emptyRelation = Relation.empty[ScopedKey[?], ScopedKey[?]] cMap.foldLeft(emptyRelation) { case (r, (key, value)) => r + (key, value.dependencies) } - private[sbt] def showDefinitions(key: AttributeKey[_], defs: Seq[Scope])(using - display: Show[ScopedKey[_]] + private[sbt] def showDefinitions(key: AttributeKey[?], defs: Seq[Scope])(using + display: Show[ScopedKey[?]] ): String = showKeys(defs.map(scope => ScopedKey(scope, key))) - private[sbt] def showUses(defs: Seq[ScopedKey[_]])(using display: Show[ScopedKey[_]]): String = + private[sbt] def showUses(defs: Seq[ScopedKey[?]])(using display: Show[ScopedKey[?]]): String = showKeys(defs) - private def showKeys(s: Seq[ScopedKey[_]])(using display: Show[ScopedKey[_]]): String = + private def showKeys(s: Seq[ScopedKey[?]])(using display: Show[ScopedKey[?]]): String = s.map(display.show).sorted.mkString("\n\t", "\n\t", "\n\n") - private[sbt] def definitions(structure: BuildStructure, actual: Boolean, key: AttributeKey[_])( - using display: Show[ScopedKey[_]] + private[sbt] def definitions(structure: BuildStructure, actual: Boolean, key: AttributeKey[?])( + using display: Show[ScopedKey[?]] ): Seq[Scope] = relation(structure, actual)(using display)._1s.toSeq flatMap { sk => if (sk.key == key) sk.scope :: Nil else Nil } - private[sbt] def usedBy(structure: BuildStructure, actual: Boolean, key: AttributeKey[_])(using - display: Show[ScopedKey[_]] - ): Seq[ScopedKey[_]] = + private[sbt] def usedBy(structure: BuildStructure, actual: Boolean, key: AttributeKey[?])(using + display: Show[ScopedKey[?]] + ): Seq[ScopedKey[?]] = relation(structure, actual)(using display).all.toSeq flatMap { case (a, b) => - if (b.key == key) List[ScopedKey[_]](a) else Nil + if (b.key == key) List[ScopedKey[?]](a) else Nil } def reverseDependencies( - cMap: Map[ScopedKey[_], Flattened], - scoped: ScopedKey[_] - ): Iterable[ScopedKey[_]] = + cMap: Map[ScopedKey[?], Flattened], + scoped: ScopedKey[?] + ): Iterable[ScopedKey[?]] = for { (key, compiled) <- cMap dep <- compiled.dependencies if dep == scoped diff --git a/main/src/main/scala/sbt/ProjectMatrix.scala b/main/src/main/scala/sbt/ProjectMatrix.scala index dd7bb7d12..058294508 100644 --- a/main/src/main/scala/sbt/ProjectMatrix.scala +++ b/main/src/main/scala/sbt/ProjectMatrix.scala @@ -38,7 +38,7 @@ sealed trait ProjectMatrix extends CompositeProject { def withId(id: String): ProjectMatrix /** Sets the base directory for this project matrix. */ - def in(dir: File): ProjectMatrix + infix def in(dir: File): ProjectMatrix /** Adds new configurations directly to this project. To override an existing configuration, use `overrideConfigs`. */ def configs(cs: Configuration*): ProjectMatrix @@ -107,22 +107,22 @@ sealed trait ProjectMatrix extends CompositeProject { def customRow( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix def customRow( autoScalaLibrary: Boolean, axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix def jvmPlatform(scalaVersions: Seq[String]): ProjectMatrix def jvmPlatform(autoScalaLibrary: Boolean): ProjectMatrix - def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[_]]): ProjectMatrix + def jvmPlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[?]]): ProjectMatrix def jvmPlatform( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix def jvmPlatform( scalaVersions: Seq[String], @@ -132,16 +132,16 @@ sealed trait ProjectMatrix extends CompositeProject { def jvmPlatform( autoScalaLibrary: Boolean, scalaVersions: Seq[String], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix def jvm: ProjectFinder def jsPlatform(scalaVersions: Seq[String]): ProjectMatrix - def jsPlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[_]]): ProjectMatrix + def jsPlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[?]]): ProjectMatrix def jsPlatform( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix def jsPlatform( scalaVersions: Seq[String], @@ -151,11 +151,11 @@ sealed trait ProjectMatrix extends CompositeProject { def js: ProjectFinder def nativePlatform(scalaVersions: Seq[String]): ProjectMatrix - def nativePlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[_]]): ProjectMatrix + def nativePlatform(scalaVersions: Seq[String], settings: Seq[Def.Setting[?]]): ProjectMatrix def nativePlatform( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix def nativePlatform( scalaVersions: Seq[String], @@ -248,7 +248,7 @@ object ProjectMatrix { val nonMatrixAggregate: Seq[ProjectReference], val dependencies: Seq[MatrixClasspathDep[ProjectMatrixReference]], val nonMatrixDependencies: Seq[ClasspathDep[ProjectReference]], - val settings: Seq[Def.Setting[_]], + val settings: Seq[Def.Setting[?]], val configurations: Seq[Configuration], val plugins: Plugins, val transforms: Seq[Project => Project], @@ -266,7 +266,7 @@ object ProjectMatrix { val idSuffix = axes.map(_.idSuffix).mkString("") val childId = self.id + idSuffix r -> childId - }): _*) + })*) } private def isSortOfDefaultAxis(a: VirtualAxis): Boolean = @@ -299,10 +299,10 @@ object ProjectMatrix { val dotSbtMatrix = new java.io.File(".sbt") / "matrix" IO.createDirectory(dotSbtMatrix) val p = Project(childId, dotSbtMatrix / childId) - .dependsOn(deps: _*) - .aggregate(aggs: _*) + .dependsOn(deps*) + .aggregate(aggs*) .setPlugins(plugins) - .configs(configurations: _*) + .configs(configurations*) .settings( name := self.id ) @@ -329,7 +329,7 @@ object ProjectMatrix { projectMatrixBaseDirectory := base, ) .settings(self.settings) - .configure(transforms: _*) + .configure(transforms*) r -> r.process(p) } @@ -388,7 +388,7 @@ object ProjectMatrix { case _ => sys.error(s"no rows were found in $id matching $thatRow: $rows") } - private def makeSources(dirSuffix: String, svDirSuffix: String): Def.Setting[_] = { + private def makeSources(dirSuffix: String, svDirSuffix: String): Def.Setting[?] = { unmanagedSourceDirectories ++= Seq( scalaSource.value.getParentFile / s"scala${dirSuffix}", scalaSource.value.getParentFile / s"scala$svDirSuffix", @@ -398,7 +398,7 @@ object ProjectMatrix { override def withId(id: String): ProjectMatrix = copy(id = id) - override def in(dir: File): ProjectMatrix = copy(base = dir) + override infix def in(dir: File): ProjectMatrix = copy(base = dir) override def configs(cs: Configuration*): ProjectMatrix = copy(configurations = configurations ++ cs) @@ -421,7 +421,7 @@ object ProjectMatrix { /** Appends settings to the current settings sequence for this project. */ override def settings(ss: Def.SettingsDefinition*): ProjectMatrix = - copy(settings = (settings: Seq[Def.Setting[_]]) ++ Def.settings(ss: _*)) + copy(settings = (settings: Seq[Def.Setting[?]]) ++ Def.settings(ss*)) override def enablePlugins(ns: Plugins*): ProjectMatrix = setPlugins(ns.foldLeft(plugins)(Plugins.and)) @@ -440,20 +440,20 @@ object ProjectMatrix { jvmPlatform(autoScalaLibrary, Nil, Nil) override def jvmPlatform( scalaVersions: Seq[String], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = jvmPlatform(true, scalaVersions, settings) override def jvmPlatform( autoScalaLibrary: Boolean, scalaVersions: Seq[String], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow(autoScalaLibrary, scalaVersions, Seq(VirtualAxis.jvm), { _.settings(settings) }) override def jvmPlatform( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow(true, scalaVersions, VirtualAxis.jvm +: axisValues, { _.settings(settings) }) @@ -482,7 +482,7 @@ object ProjectMatrix { override def jsPlatform( scalaVersions: Seq[String], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow( true, @@ -494,7 +494,7 @@ object ProjectMatrix { override def jsPlatform( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow( true, @@ -545,7 +545,7 @@ object ProjectMatrix { override def nativePlatform( scalaVersions: Seq[String], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow( true, @@ -557,7 +557,7 @@ object ProjectMatrix { override def nativePlatform( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow( true, @@ -615,13 +615,13 @@ object ProjectMatrix { override def customRow( scalaVersions: Seq[String], axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow(true, scalaVersions, axisValues, { _.settings(settings) }) override def customRow( autoScalaLibrary: Boolean, axisValues: Seq[VirtualAxis], - settings: Seq[Def.Setting[_]] + settings: Seq[Def.Setting[?]] ): ProjectMatrix = customRow(autoScalaLibrary, Nil, axisValues, { _.settings(settings) }) override def customRow( @@ -674,7 +674,7 @@ object ProjectMatrix { nonMatrixAggregate: Seq[ProjectReference] = nonMatrixAggregate, dependencies: Seq[MatrixClasspathDep[ProjectMatrixReference]] = dependencies, nonMatrixDependencies: Seq[ClasspathDep[ProjectReference]] = nonMatrixDependencies, - settings: Seq[Def.Setting[_]] = settings, + settings: Seq[Def.Setting[?]] = settings, configurations: Seq[Configuration] = configurations, plugins: Plugins = plugins, transforms: Seq[Project => Project] = transforms, @@ -734,7 +734,7 @@ object ProjectMatrix { nonMatrixAggregate: Seq[ProjectReference], dependencies: Seq[MatrixClasspathDep[ProjectMatrixReference]], nonMatrixDependencies: Seq[ClasspathDep[ProjectReference]], - settings: Seq[Def.Setting[_]], + settings: Seq[Def.Setting[?]], configurations: Seq[Configuration], plugins: Plugins, transforms: Seq[Project => Project], diff --git a/main/src/main/scala/sbt/RemoteCache.scala b/main/src/main/scala/sbt/RemoteCache.scala index 1c57f38c8..0a9874e8c 100644 --- a/main/src/main/scala/sbt/RemoteCache.scala +++ b/main/src/main/scala/sbt/RemoteCache.scala @@ -71,7 +71,7 @@ object RemoteCache { lazy val defaultCacheLocation: File = SysProp.globalLocalCache - lazy val globalSettings: Seq[Def.Setting[_]] = Seq( + lazy val globalSettings: Seq[Def.Setting[?]] = Seq( remoteCacheId := "", remoteCacheIdCandidates := Nil, pushRemoteCacheTo :== None, @@ -101,7 +101,7 @@ object RemoteCache { remoteCacheHeaders := SysProp.remoteCacheHeaders, ) - lazy val projectSettings: Seq[Def.Setting[_]] = (Seq( + lazy val projectSettings: Seq[Def.Setting[?]] = (Seq( pushRemoteCache := ((Def .task { val arts = (pushRemoteCacheConfiguration / remoteCacheArtifacts).value @@ -111,7 +111,7 @@ object RemoteCache { case _ => None } } - ScopeFilter(configurations = inConfigurationsByKeys(configs: _*)) + ScopeFilter(configurations = inConfigurationsByKeys(configs*)) }) .flatMapTask { case filter => Def.task { @@ -129,7 +129,7 @@ object RemoteCache { case _ => None } } - ScopeFilter(configurations = inConfigurationsByKeys(configs: _*)) + ScopeFilter(configurations = inConfigurationsByKeys(configs*)) }) .flatMapTask { case filter => Def.task { @@ -203,7 +203,7 @@ object RemoteCache { def configCacheSettings[A <: RemoteCacheArtifact]( cacheArtifactTask: Def.Initialize[Task[A]] - ): Seq[Def.Setting[_]] = + ): Seq[Def.Setting[?]] = inTask(packageCache)( Seq( (Defaults.TaskZero / packageCache) := { @@ -243,13 +243,16 @@ object RemoteCache { ModuleDescriptorConfiguration(remoteCacheProjectId.value, projectInfo.value) .withScalaModuleInfo(smi) }, - (Defaults.TaskZero / pushRemoteCache) := (Def.task { - val s = streams.value - val config = pushRemoteCacheConfiguration.value - val is = (pushRemoteCache / ivySbt).value - val m = new is.Module(moduleSettings.value) - IvyActions.publish(m, config, s.log) - } tag (Tags.Publish, Tags.Network)).value, + (Defaults.TaskZero / pushRemoteCache) := (Def + .task { + val s = streams.value + val config = pushRemoteCacheConfiguration.value + val is = (pushRemoteCache / ivySbt).value + val m = new is.Module(moduleSettings.value) + IvyActions.publish(m, config, s.log) + } + .tag(Tags.Publish, Tags.Network)) + .value, ) ) ++ Seq( remoteCacheIdCandidates := List(remoteCacheId.value), diff --git a/main/src/main/scala/sbt/Resolvers.scala b/main/src/main/scala/sbt/Resolvers.scala index beb361026..14312c732 100644 --- a/main/src/main/scala/sbt/Resolvers.scala +++ b/main/src/main/scala/sbt/Resolvers.scala @@ -132,7 +132,7 @@ object Resolvers { } def run(command: String*): Unit = - run(None, command: _*) + run(None, command*) def run(cwd: Option[File], command: String*): Unit = { val result = Process( diff --git a/main/src/main/scala/sbt/ScopeFilter.scala b/main/src/main/scala/sbt/ScopeFilter.scala index 08f78d390..eff4e9b02 100644 --- a/main/src/main/scala/sbt/ScopeFilter.scala +++ b/main/src/main/scala/sbt/ScopeFilter.scala @@ -39,13 +39,13 @@ sealed abstract class ScopeFilter { self => object ScopeFilter { type ProjectFilter = AxisFilter[Reference] type ConfigurationFilter = AxisFilter[ConfigKey] - type TaskFilter = AxisFilter[AttributeKey[_]] + type TaskFilter = AxisFilter[AttributeKey[?]] private type ScopeMap = Map[ ScopeAxis[Reference], Map[ ScopeAxis[ConfigKey], - Map[ScopeAxis[AttributeKey[_]], Set[Scope]] + Map[ScopeAxis[AttributeKey[?]], Set[Scope]] ] ] @@ -113,7 +113,7 @@ object ScopeFilter { trait Make { /** Selects Scopes with a Zero task axis. */ - def inZeroTask: TaskFilter = zeroAxis[AttributeKey[_]] + def inZeroTask: TaskFilter = zeroAxis[AttributeKey[?]] @deprecated("Use inZeroTask", "1.0.0") def inGlobalTask: TaskFilter = inZeroTask @@ -135,7 +135,7 @@ object ScopeFilter { selectAxis(const { case _: ProjectRef => true; case _ => false }) /** Accepts all values for the task axis except Zero. */ - def inAnyTask: TaskFilter = selectAny[AttributeKey[_]] + def inAnyTask: TaskFilter = selectAny[AttributeKey[?]] /** Accepts all values for the configuration axis except Zero. */ def inAnyConfiguration: ConfigurationFilter = selectAny[ConfigKey] @@ -176,12 +176,12 @@ object ScopeFilter { /** Selects Scopes that have a project axis with one of the provided values. */ def inProjects(projects: ProjectReference*): ProjectFilter = - ScopeFilter.inProjects(projects: _*) + ScopeFilter.inProjects(projects*) /** Selects Scopes that have a task axis with one of the provided values. */ def inTasks(tasks: Scoped*): TaskFilter = { val ts = tasks.map(_.key).toSet - selectAxis[AttributeKey[_]](const(ts)) + selectAxis[AttributeKey[?]](const(ts)) } /** Selects Scopes that have a task axis with one of the provided values. */ diff --git a/main/src/main/scala/sbt/ScriptedPlugin.scala b/main/src/main/scala/sbt/ScriptedPlugin.scala index 5ebfd6316..cc6fbdfcf 100644 --- a/main/src/main/scala/sbt/ScriptedPlugin.scala +++ b/main/src/main/scala/sbt/ScriptedPlugin.scala @@ -55,12 +55,12 @@ object ScriptedPlugin extends AutoPlugin { } import autoImport._ - override lazy val globalSettings: Seq[Setting[_]] = Seq( + override lazy val globalSettings: Seq[Setting[?]] = Seq( scriptedBufferLog := true, scriptedLaunchOpts := Seq(), ) - override lazy val projectSettings: Seq[Setting[_]] = Seq( + override lazy val projectSettings: Seq[Setting[?]] = Seq( ivyConfigurations ++= Seq(ScriptedConf, ScriptedLaunchConf), scriptedSbt := (pluginCrossBuild / sbtVersion).value, sbtLauncher := getJars(ScriptedLaunchConf) @@ -161,10 +161,10 @@ object ScriptedPlugin extends AutoPlugin { } yield files map (f => s"$group/$f") val testID = (for (group <- groupP; name <- nameP(group)) yield (group, name)) - val testIdAsGroup = matched(testID) map (test => Seq(test)) + val testIdAsGroup = matched(testID).map(test => Seq(test)) // (token(Space) ~> matched(testID)).* - (token(Space) ~> (PagedIds | testIdAsGroup)).* map (_.flatten) + (token(Space) ~> (PagedIds | testIdAsGroup)).*.map(_.flatten) } private[sbt] def scriptedTask: Initialize[InputTask[Unit]] = diff --git a/main/src/main/scala/sbt/SessionVar.scala b/main/src/main/scala/sbt/SessionVar.scala index f745130c8..40a36b587 100644 --- a/main/src/main/scala/sbt/SessionVar.scala +++ b/main/src/main/scala/sbt/SessionVar.scala @@ -24,8 +24,8 @@ object SessionVar { // these are required because of inference+manifest limitations final case class Key[T](key: ScopedKey[Task[T]]) final case class Map(map: IMap[Key, Id]) { - def get[T](k: ScopedKey[Task[T]]): Option[T] = map get Key(k) - def put[T](k: ScopedKey[Task[T]], v: T): Map = Map(map put (Key(k), v)) + def get[T](k: ScopedKey[Task[T]]): Option[T] = map.get(Key(k)) + def put[T](k: ScopedKey[Task[T]], v: T): Map = Map(map.put(Key(k), v)) } def emptyMap = Map(IMap.empty) @@ -42,12 +42,12 @@ object SessionVar { def clear(s: State): State = s.put(sessionVars, SessionVar.emptyMap) def get[T](key: ScopedKey[Task[T]], state: State): Option[T] = - orEmpty(state get sessionVars) get key + orEmpty(state.get(sessionVars)).get(key) def set[T](key: ScopedKey[Task[T]], state: State, value: T): State = - state.update(sessionVars)(om => orEmpty(om) put (key, value)) + state.update(sessionVars)(om => orEmpty(om).put(key, value)) - def orEmpty(opt: Option[Map]) = opt getOrElse emptyMap + def orEmpty(opt: Option[Map]) = opt.getOrElse(emptyMap) def transform[S](task: Task[S], f: (State, S) => State): Task[S] = { val g = (s: S, map: AttributeMap) => map.put(Keys.transformState, (state: State) => f(state, s)) diff --git a/main/src/main/scala/sbt/TemplateCommandUtil.scala b/main/src/main/scala/sbt/TemplateCommandUtil.scala index 35f6d2de4..c9ff55081 100644 --- a/main/src/main/scala/sbt/TemplateCommandUtil.scala +++ b/main/src/main/scala/sbt/TemplateCommandUtil.scala @@ -32,14 +32,14 @@ private[sbt] object TemplateCommandUtil { ) private def templateCommandParser: Parser[Seq[String]] = - (token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF) map (_ => Nil)) + (token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF).map(_ => Nil)) private def runTemplate(s0: State, inputArg: Seq[String]): State = { import BuildPaths._ val globalBase = getGlobalBase(s0) - val infos = (s0 get templateResolverInfos getOrElse Nil).toList + val infos = s0.get(templateResolverInfos).getOrElse(Nil).toList val log = s0.globalLogging.full - val extracted = (Project extract s0) + val extracted = Project.extract(s0) val (s1, ivyConf) = extracted.runTask(Keys.ivyConfiguration, s0) val scalaModuleInfo = extracted.get(Keys.updateSbtClassifiers / Keys.scalaModuleInfo) val templateDescriptions = extracted.get(Keys.templateDescriptions) @@ -123,12 +123,12 @@ private[sbt] object TemplateCommandUtil { interfaceClassName: String, methodName: String, loader: ClassLoader - )(argTypes: Class[_]*)(args: AnyRef*): AnyRef = { + )(argTypes: Class[?]*)(args: AnyRef*): AnyRef = { val interfaceClass = getInterfaceClass(interfaceClassName, loader) val interface = interfaceClass.getDeclaredConstructor().newInstance().asInstanceOf[AnyRef] - val method = interfaceClass.getMethod(methodName, argTypes: _*) + val method = interfaceClass.getMethod(methodName, argTypes*) try { - method.invoke(interface, args: _*) + method.invoke(interface, args*) } catch { case e: InvocationTargetException => throw e.getCause } @@ -150,7 +150,7 @@ private[sbt] object TemplateCommandUtil { val templateId = s"${info.module.organization}_${info.module.name}_${info.module.revision}" val templateDirectory = new File(templatesBaseDirectory, templateId) def jars = (templateDirectory ** -DirectoryFilter).get() - if (!(info.module.revision endsWith "-SNAPSHOT") && jars.nonEmpty) jars.toList.map(_.toPath) + if !info.module.revision.endsWith("-SNAPSHOT") && jars.nonEmpty then jars.toList.map(_.toPath) else { IO.createDirectory(templateDirectory) val m = lm.wrapDependencyInModule(info.module, scalaModuleInfo) @@ -195,7 +195,7 @@ private[sbt] object TemplateCommandUtil { out.println("Welcome to sbt new!") out.println("Here are some templates to get started:") val ans = askTemplate(mappingList, 0) - val mappings = Map(mappingList: _*) + val mappings = Map(mappingList*) mappings.get(ans).map(_._1).toList } diff --git a/main/src/main/scala/sbt/UpperStateOps.scala b/main/src/main/scala/sbt/UpperStateOps.scala index 0ca038eda..e8bdbd410 100644 --- a/main/src/main/scala/sbt/UpperStateOps.scala +++ b/main/src/main/scala/sbt/UpperStateOps.scala @@ -98,13 +98,13 @@ trait UpperStateOps extends Any { def unsafeRunAggregated[A](key: TaskKey[A]): State /** Appends the given settings to all the build state settings, including session settings. */ - def appendWithSession(settings: Seq[Setting[_]]): State + def appendWithSession(settings: Seq[Setting[?]]): State /** * Appends the given settings to the original build state settings, discarding any settings * appended to the session in the process. */ - def appendWithoutSession(settings: Seq[Setting[_]], state: State): State + def appendWithoutSession(settings: Seq[Setting[?]], state: State): State def respondEvent[A: JsonFormat](event: A): Unit def respondError(code: Long, message: String): Unit @@ -143,10 +143,10 @@ object UpperStateOps { def unsafeRunAggregated[A](key: TaskKey[A]): State = extract.runAggregated(key, s) - def appendWithSession(settings: Seq[Setting[_]]): State = + def appendWithSession(settings: Seq[Setting[?]]): State = extract.appendWithSession(settings, s) - def appendWithoutSession(settings: Seq[Setting[_]], state: State): State = + def appendWithoutSession(settings: Seq[Setting[?]], state: State): State = extract.appendWithoutSession(settings, s) def respondEvent[A: JsonFormat](event: A): Unit = { diff --git a/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala b/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala index ac79c66d9..d448d5ed5 100644 --- a/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala +++ b/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala @@ -166,7 +166,7 @@ object CoursierInputsTasks { val state = sbt.Keys.state.value val projectRef = sbt.Keys.thisProjectRef.value val projectRefs = Project.transitiveInterDependencies(state, projectRef) - ScopeFilter(inProjects(projectRefs :+ projectRef: _*)) + ScopeFilter(inProjects(projectRefs :+ projectRef*)) }) .flatMapTask { case filter => Def.task { @@ -214,7 +214,7 @@ object CoursierInputsTasks { val s = state.value val projectRef = thisProjectRef.value val projects = Project.transitiveInterDependencies(s, projectRef) - ScopeFilter(inProjects(projectRef +: projects: _*)) + ScopeFilter(inProjects(projectRef +: projects*)) }) .flatMapTask { case filter => Def.task { diff --git a/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala b/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala index 3134425d1..e5be974af 100644 --- a/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala +++ b/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala @@ -131,7 +131,7 @@ object CoursierRepositoriesTasks { val s = state.value val projectRef = thisProjectRef.value val dependencyRefs = Project.transitiveInterDependencies(s, projectRef) - (ScopeFilter(inProjects(projectRef)), ScopeFilter(inProjects(dependencyRefs: _*))) + (ScopeFilter(inProjects(projectRef)), ScopeFilter(inProjects(dependencyRefs*))) }) .flatMapTask { case (filter1, filter2) => Def.task { diff --git a/main/src/main/scala/sbt/coursierint/LMCoursier.scala b/main/src/main/scala/sbt/coursierint/LMCoursier.scala index 3e5fd18ca..f3f9d0195 100644 --- a/main/src/main/scala/sbt/coursierint/LMCoursier.scala +++ b/main/src/main/scala/sbt/coursierint/LMCoursier.scala @@ -251,8 +251,8 @@ object LMCoursier { logger.debug(s"downloaded $url") } - def publicationsSetting(packageConfigs: Seq[(Configuration, CConfiguration)]): Def.Setting[_] = { - csrPublications := CoursierArtifactsTasks.coursierPublicationsTask(packageConfigs: _*).value + def publicationsSetting(packageConfigs: Seq[(Configuration, CConfiguration)]): Def.Setting[?] = { + csrPublications := CoursierArtifactsTasks.coursierPublicationsTask(packageConfigs*).value } // This emulates Ivy's credential registration which basically keeps mutating global registry diff --git a/main/src/main/scala/sbt/internal/AbstractTaskProgress.scala b/main/src/main/scala/sbt/internal/AbstractTaskProgress.scala index 1502e7894..626f041f1 100644 --- a/main/src/main/scala/sbt/internal/AbstractTaskProgress.scala +++ b/main/src/main/scala/sbt/internal/AbstractTaskProgress.scala @@ -20,9 +20,9 @@ private[sbt] abstract class AbstractTaskExecuteProgress extends ExecuteProgress import AbstractTaskExecuteProgress.Timer private val showScopedKey = Def.showShortKey(None) - private val anonOwners = new ConcurrentHashMap[TaskId[_], TaskId[_]] - private val calledBy = new ConcurrentHashMap[TaskId[_], TaskId[_]] - private val timings = new ConcurrentHashMap[TaskId[_], Timer] + private val anonOwners = new ConcurrentHashMap[TaskId[?], TaskId[?]] + private val calledBy = new ConcurrentHashMap[TaskId[?], TaskId[?]] + private val timings = new ConcurrentHashMap[TaskId[?], Timer] private[sbt] def timingsByName: mutable.Map[String, AtomicLong] = { val result = new ConcurrentHashMap[String, AtomicLong] timings.forEach { (task, timing) => @@ -35,18 +35,18 @@ private[sbt] abstract class AbstractTaskExecuteProgress extends ExecuteProgress result.asScala } private[sbt] def anyTimings = !timings.isEmpty - def currentTimings: Iterator[(TaskId[_], Timer)] = timings.asScala.iterator + def currentTimings: Iterator[(TaskId[?], Timer)] = timings.asScala.iterator - private[internal] def exceededThreshold(task: TaskId[_], threshold: FiniteDuration): Boolean = + private[internal] def exceededThreshold(task: TaskId[?], threshold: FiniteDuration): Boolean = timings.get(task) match { case null => false case t => t.durationMicros > threshold.toMicros } private[internal] def timings( - tasks: java.util.Set[TaskId[_]], + tasks: java.util.Set[TaskId[?]], thresholdMicros: Long - ): Vector[(TaskId[_], Long)] = { - val result = new VectorBuilder[(TaskId[_], Long)] + ): Vector[(TaskId[?], Long)] = { + val result = new VectorBuilder[(TaskId[?], Long)] val now = System.nanoTime tasks.forEach { t => timings.get(t) match { @@ -61,7 +61,7 @@ private[sbt] abstract class AbstractTaskExecuteProgress extends ExecuteProgress result.result() } def activeTasks(now: Long) = { - val result = new VectorBuilder[(TaskId[_], FiniteDuration)] + val result = new VectorBuilder[(TaskId[?], FiniteDuration)] timings.forEach { (task, timing) => if (timing.isActive) result += task -> (now - timing.startNanos).nanos } @@ -102,19 +102,19 @@ private[sbt] abstract class AbstractTaskExecuteProgress extends ExecuteProgress } } - private val taskNameCache = new ConcurrentHashMap[TaskId[_], String] - protected def taskName(t: TaskId[_]): String = taskNameCache.get(t) match { + private val taskNameCache = new ConcurrentHashMap[TaskId[?], String] + protected def taskName(t: TaskId[?]): String = taskNameCache.get(t) match { case null => val name = taskName0(t) taskNameCache.putIfAbsent(t, name) name case name => name } - private def taskName0(t: TaskId[_]): String = { - def definedName(node: Task[_]): Option[String] = + private def taskName0(t: TaskId[?]): String = { + def definedName(node: Task[?]): Option[String] = node.info.name.orElse(TaskName.transformNode(node).map(showScopedKey.show)) - def inferredName(t: Task[_]): Option[String] = nameDelegate(t) map taskName - def nameDelegate(t: Task[_]): Option[TaskId[_]] = + def inferredName(t: Task[?]): Option[String] = nameDelegate(t) map taskName + def nameDelegate(t: Task[?]): Option[TaskId[?]] = Option(anonOwners.get(t)).orElse(Option(calledBy.get(t))) t match case t: Task[?] => definedName(t).orElse(inferredName(t)).getOrElse(TaskName.anonymousName(t)) diff --git a/main/src/main/scala/sbt/internal/Act.scala b/main/src/main/scala/sbt/internal/Act.scala index bd4fa0dd6..c5ca91bfa 100644 --- a/main/src/main/scala/sbt/internal/Act.scala +++ b/main/src/main/scala/sbt/internal/Act.scala @@ -30,7 +30,7 @@ import sbt.internal.util.{ import sbt.util.Show import scala.collection.mutable -final class ParsedKey(val key: ScopedKey[_], val mask: ScopeMask): +final class ParsedKey(val key: ScopedKey[?], val mask: ScopeMask): override def equals(o: Any): Boolean = this.eq(o.asInstanceOf[AnyRef]) || (o match { case x: ParsedKey => (this.key == x.key) && (this.mask == x.mask) @@ -60,7 +60,7 @@ object Act { index: KeyIndex, current: ProjectRef, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], data: Settings[Scope] ): Parser[ScopedKey[Any]] = scopedKeySelected(index, current, defaultConfigs, keyMap, data, askProject = true) @@ -114,7 +114,7 @@ object Act { index: KeyIndex, current: ProjectRef, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], data: Settings[Scope], askProject: Boolean, ): Parser[ParsedKey] = @@ -127,7 +127,7 @@ object Act { index: KeyIndex, current: ProjectRef, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], askProject: Boolean, ): Parser[Seq[Parser[ParsedKey]]] = { val confParserCache: mutable.Map[Option[sbt.ResolvedReference], Parser[ParsedAxis[String]]] = @@ -168,7 +168,7 @@ object Act { def taskKeyExtra( index: KeyIndex, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], proj: Option[ResolvedReference], confAmb: ParsedAxis[String], baseMask: ScopeMask, @@ -188,17 +188,17 @@ object Act { def makeScopedKey( proj: Option[ResolvedReference], conf: Option[String], - task: Option[AttributeKey[_]], + task: Option[AttributeKey[?]], extra: ScopeAxis[AttributeMap], - key: AttributeKey[_] - ): ScopedKey[_] = + key: AttributeKey[?] + ): ScopedKey[?] = ScopedKey( Scope(toAxis(proj, Zero), toAxis(conf map ConfigKey.apply, Zero), toAxis(task, Zero), extra), key ) def select(allKeys: Seq[Parser[ParsedKey]], data: Settings[Scope])(implicit - show: Show[ScopedKey[_]] + show: Show[ScopedKey[?]] ): Parser[ParsedKey] = seq(allKeys) flatMap { ss => val default: Parser[ParsedKey] = ss.headOption match @@ -208,14 +208,14 @@ object Act { } def selectFromValid(ss: Seq[ParsedKey], default: Parser[ParsedKey])(implicit - show: Show[ScopedKey[_]] + show: Show[ScopedKey[?]] ): Parser[ParsedKey] = selectByTask(selectByConfig(ss)) match { case Seq() => default case Seq(single) => success(single) case multi => failure("Ambiguous keys: " + showAmbiguous(keys(multi))) } - private def keys(ss: Seq[ParsedKey]): Seq[ScopedKey[_]] = ss.map(_.key) + private def keys(ss: Seq[ParsedKey]): Seq[ScopedKey[?]] = ss.map(_.key) def selectByConfig(ss: Seq[ParsedKey]): Seq[ParsedKey] = ss match { case Seq() => Nil @@ -232,7 +232,7 @@ object Act { def noValidKeys = failure("No such key.") - def showAmbiguous(keys: Seq[ScopedKey[_]])(implicit show: Show[ScopedKey[_]]): String = + def showAmbiguous(keys: Seq[ScopedKey[?]])(implicit show: Show[ScopedKey[?]]): String = keys.take(3).map(x => show.show(x)).mkString("", ", ", if (keys.size > 3) ", ..." else "") def isValid(data: Settings[Scope])(parsed: ParsedKey): Boolean = { @@ -241,7 +241,7 @@ object Act { } def examples(p: Parser[String], exs: Set[String], label: String): Parser[String] = - p !!! ("Expected " + label) examples exs + (p !!! ("Expected " + label)).examples(exs) def examplesStrict(p: Parser[String], exs: Set[String], label: String): Parser[String] = filterStrings(examples(p, exs, label), exs, label) @@ -286,7 +286,7 @@ object Act { index: KeyIndex, defaultConfigs: Option[ResolvedReference] => Seq[String] ): Seq[String] = - if (index exists proj) defaultConfigs(proj) else Nil + if index.exists(proj) then defaultConfigs(proj) else Nil def nonEmptyConfig( index: KeyIndex, @@ -298,14 +298,14 @@ object Act { index: KeyIndex, proj: Option[ResolvedReference], conf: Option[String], - task: Option[AttributeKey[_]], - keyMap: Map[String, AttributeKey[_]] - ): Parser[AttributeKey[_]] = { + task: Option[AttributeKey[?]], + keyMap: Map[String, AttributeKey[?]] + ): Parser[AttributeKey[?]] = { def dropHyphenated(keys: Set[String]): Set[String] = keys.filterNot(Util.hasHyphen) - def keyParser(keys: Set[String]): Parser[AttributeKey[_]] = - token(ID !!! "Expected key" examples dropHyphenated(keys)) flatMap { keyString => + def keyParser(keys: Set[String]): Parser[AttributeKey[?]] = + token((ID !!! "Expected key").examples(dropHyphenated(keys))).flatMap: keyString => getKey(keyMap, keyString, idFun) - } + // Fixes sbt/sbt#2460 and sbt/sbt#2851 // The parser already accepts build-level keys. // This queries the key index so tab completion will list the build-level keys. @@ -324,9 +324,9 @@ object Act { } def getKey[T]( - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], keyString: String, - f: AttributeKey[_] => T + f: AttributeKey[?] => T ): Parser[T] = keyMap.get(keyString) match { case Some(k) => success(f(k)) @@ -336,7 +336,7 @@ object Act { val spacedComma = token(OptSpace ~ ',' ~ OptSpace) def extraAxis( - knownKeys: Map[String, AttributeKey[_]], + knownKeys: Map[String, AttributeKey[?]], knownValues: IMap[AttributeKey, Set] ): Parser[ScopeAxis[AttributeMap]] = { val extrasP = extrasParser(knownKeys, knownValues) @@ -346,11 +346,11 @@ object Act { } def taskAxis( - tasks: Set[AttributeKey[_]], - allKnown: Map[String, AttributeKey[_]], - ): Parser[ParsedAxis[AttributeKey[_]]] = { + tasks: Set[AttributeKey[?]], + allKnown: Map[String, AttributeKey[?]], + ): Parser[ParsedAxis[AttributeKey[?]]] = { val taskSeq = tasks.toSeq - def taskKeys(f: AttributeKey[_] => String): Seq[(String, AttributeKey[_])] = + def taskKeys(f: AttributeKey[?] => String): Seq[(String, AttributeKey[?])] = taskSeq.map(key => (f(key), key)) val normKeys = taskKeys(_.label) val valid = allKnown ++ normKeys @@ -362,7 +362,7 @@ object Act { ) <~ spacedSlash) ?? Omitted } - def resolveTask(task: ParsedAxis[AttributeKey[_]]): Option[AttributeKey[_]] = + def resolveTask(task: ParsedAxis[AttributeKey[?]]): Option[AttributeKey[?]] = task match { case ParsedZero | ParsedGlobal | Omitted => None case t: ParsedValue[AttributeKey[_]] @unchecked => Some(t.value) @@ -372,20 +372,20 @@ object Act { base.filter(valid, Command.invalidValue(label, valid)) def extrasParser( - knownKeys: Map[String, AttributeKey[_]], + knownKeys: Map[String, AttributeKey[?]], knownValues: IMap[AttributeKey, Set] ): Parser[AttributeMap] = { - val validKeys = knownKeys.filter { case (_, key) => knownValues get key exists (_.nonEmpty) } + val validKeys = knownKeys.filter { case (_, key) => knownValues.get(key).exists(_.nonEmpty) } if (validKeys.isEmpty) failure("No valid extra keys.") else - rep1sep(extraParser(validKeys, knownValues), spacedComma) map AttributeMap.apply + rep1sep(extraParser(validKeys, knownValues), spacedComma).map(AttributeMap.apply) } def extraParser( - knownKeys: Map[String, AttributeKey[_]], + knownKeys: Map[String, AttributeKey[?]], knownValues: IMap[AttributeKey, Set] - ): Parser[AttributeEntry[_]] = { + ): Parser[AttributeEntry[?]] = { val keyp = knownIDParser(knownKeys, "Not a valid extra key") <~ token(':' ~ OptSpace) keyp flatMap { case key: AttributeKey[t] => val valueMap: Map[String, t] = knownValues(key).map(v => (v.toString, v)).toMap @@ -395,11 +395,11 @@ object Act { } } def knownIDParser[T](knownKeys: Map[String, T], label: String): Parser[T] = - token(examplesStrict(ID, knownKeys.keys.toSet, label)) map knownKeys + token(examplesStrict(ID, knownKeys.keys.toSet, label)).map(knownKeys) def knownPluginParser[T](knownPlugins: Map[String, T], label: String): Parser[T] = { val pluginLabelParser = rep1sep(ID, '.').map(_.mkString(".")) - token(examplesStrict(pluginLabelParser, knownPlugins.keys.toSet, label)) map knownPlugins + token(examplesStrict(pluginLabelParser, knownPlugins.keys.toSet, label)).map(knownPlugins) } def projectRef(index: KeyIndex, currentBuild: URI): Parser[ParsedAxis[ResolvedReference]] = { @@ -414,13 +414,13 @@ object Act { private[sbt] def resolvedReferenceIdent( index: KeyIndex, currentBuild: URI, - trailing: Parser[_] + trailing: Parser[?] ): Parser[ResolvedReference] = { def projectID(uri: URI) = token( DQuoteChar ~> examplesStrict( ID, - index projects uri, + index.projects(uri), "project ID" ) <~ DQuoteChar <~ OptSpace <~ ")" <~ trailing ) @@ -443,10 +443,10 @@ object Act { def resolvedReference( index: KeyIndex, currentBuild: URI, - trailing: Parser[_] + trailing: Parser[?] ): Parser[ResolvedReference] = { def projectID(uri: URI) = - token(examplesStrict(ID, index projects uri, "project ID") <~ trailing) + token(examplesStrict(ID, index.projects(uri), "project ID") <~ trailing) def projectRef(uri: URI) = projectID(uri) map { id => ProjectRef(uri, id) } @@ -485,7 +485,7 @@ object Act { // but fail the task. Otherwise, the composed parser would think we made a typo. def emptyResult: Parser[() => State] = Parser.success(() => throw MessageOnlyException("query result is empty")) - def evaluate(kvs: Seq[ScopedKey[_]]): Parser[() => State] = + def evaluate(kvs: Seq[ScopedKey[?]]): Parser[() => State] = val preparedPairs = anyKeyValues(structure, kvs) val showConfig = action match case PrintAction => @@ -518,9 +518,9 @@ object Act { end actParser0 private def applyQuery( - pairs: Seq[(ScopedKey[_], Option[ProjectQuery])], + pairs: Seq[(ScopedKey[?], Option[ProjectQuery])], structure: BuildStructure, - ): Seq[(ScopedKey[_], Option[ProjectQuery])] = + ): Seq[(ScopedKey[?], Option[ProjectQuery])] = pairs.filter { case (_, None) => true case (keys, Some(query)) => @@ -540,10 +540,10 @@ object Act { (MultiTaskCommand ^^^ MultiAction)) <~ Space ) ?? SingleAction - def scopedKeyParser(state: State): Parser[ScopedKey[_]] = scopedKeyParser(Project extract state) - def scopedKeyParser(extracted: Extracted): Parser[ScopedKey[_]] = + def scopedKeyParser(state: State): Parser[ScopedKey[?]] = scopedKeyParser(Project.extract(state)) + def scopedKeyParser(extracted: Extracted): Parser[ScopedKey[?]] = scopedKeyParser(extracted.structure, extracted.currentRef) - def scopedKeyParser(structure: BuildStructure, currentRef: ProjectRef): Parser[ScopedKey[_]] = + def scopedKeyParser(structure: BuildStructure, currentRef: ProjectRef): Parser[ScopedKey[?]] = scopedKey( structure.index.keyIndex, currentRef, @@ -552,7 +552,7 @@ object Act { structure.data ) - def aggregatedKeyParser(state: State): KeysParser = aggregatedKeyParser(Project extract state) + def aggregatedKeyParser(state: State): KeysParser = aggregatedKeyParser(Project.extract(state)) def aggregatedKeyParser(extracted: Extracted): KeysParser = aggregatedKeyParser(extracted.structure, extracted.currentRef) def aggregatedKeyParser(structure: BuildStructure, currentRef: ProjectRef): KeysParser = @@ -567,7 +567,7 @@ object Act { scopedKeyAggregatedFilter(currentRef, structure.extra.configurationsForAxis, structure) def keyValues[T](state: State)(keys: Seq[ScopedKey[T]]): Values[T] = - keyValues(Project extract state)(keys) + keyValues(Project.extract(state))(keys) def keyValues[T](extracted: Extracted)(keys: Seq[ScopedKey[T]]): Values[T] = keyValues(extracted.structure)(keys) def keyValues[T](structure: BuildStructure)(keys: Seq[ScopedKey[T]]): Values[T] = @@ -578,8 +578,8 @@ object Act { } private def anyKeyValues( structure: BuildStructure, - keys: Seq[ScopedKey[_]] - ): Seq[KeyValue[_]] = + keys: Seq[ScopedKey[?]] + ): Seq[KeyValue[?]] = keys.flatMap { key => getValue(structure.data, key.scope, key.key) map { value => KeyValue(key, value) diff --git a/main/src/main/scala/sbt/internal/AddSettings.scala b/main/src/main/scala/sbt/internal/AddSettings.scala index 8d4b75210..09fe71cdc 100644 --- a/main/src/main/scala/sbt/internal/AddSettings.scala +++ b/main/src/main/scala/sbt/internal/AddSettings.scala @@ -62,9 +62,9 @@ object AddSettings { /** Combines two automatic setting configurations. */ def append(a: AddSettings, b: AddSettings): AddSettings = (a, b) match { - case (sa: Sequence, sb: Sequence) => seq(sa.sequence ++ sb.sequence: _*) - case (sa: Sequence, _) => seq(sa.sequence :+ b: _*) - case (_, sb: Sequence) => seq(a +: sb.sequence: _*) + case (sa: Sequence, sb: Sequence) => seq(sa.sequence ++ sb.sequence*) + case (sa: Sequence, _) => seq(sa.sequence :+ b*) + case (_, sb: Sequence) => seq(a +: sb.sequence*) case _ => seq(a, b) } diff --git a/main/src/main/scala/sbt/internal/Aggregation.scala b/main/src/main/scala/sbt/internal/Aggregation.scala index fd96ddaad..924edc4f3 100644 --- a/main/src/main/scala/sbt/internal/Aggregation.scala +++ b/main/src/main/scala/sbt/internal/Aggregation.scala @@ -38,7 +38,7 @@ object Aggregation { state: State ) - final case class KeyValue[+T](key: ScopedKey[_], value: T) + final case class KeyValue[+T](key: ScopedKey[?], value: T) def defaultShow(state: State, showTasks: Boolean): ShowConfig = ShowConfig( @@ -48,8 +48,8 @@ object Aggregation { success = true ) - def printSettings(xs: Seq[KeyValue[_]], print: String => Unit)(implicit - display: Show[ScopedKey[_]] + def printSettings(xs: Seq[KeyValue[?]], print: String => Unit)(implicit + display: Show[ScopedKey[?]] ): Unit = xs match { case KeyValue(_, x: Seq[_]) :: Nil => print(x.mkString("* ", "\n* ", "")) @@ -68,7 +68,7 @@ object Aggregation { s: State, ps: Values[Parser[Task[T]]], show: ShowConfig - )(implicit display: Show[ScopedKey[_]]): Parser[() => State] = + )(implicit display: Show[ScopedKey[?]]): Parser[() => State] = Command.applyEffect(seqParser(ps))(ts => runTasks(s, ts, DummyTaskMap(Nil), show)) private def showRun[A](complete: Complete[A], show: ShowConfig)(implicit @@ -125,7 +125,7 @@ object Aggregation { ts: Values[Task[A1]], extra: DummyTaskMap, show: ShowConfig - )(using display: Show[ScopedKey[_]]): State = + )(using display: Show[ScopedKey[?]]): State = val complete = timedRun[A1](s, ts, extra) showRun(complete, show) complete.results match @@ -187,7 +187,7 @@ object Aggregation { s: State, inputs: Values[InputTask[I]], show: ShowConfig - )(implicit display: Show[ScopedKey[_]]): Parser[() => State] = { + )(implicit display: Show[ScopedKey[?]]): Parser[() => State] = { val parsers = for (KeyValue(k, it) <- inputs) yield it.parser(s).map(v => KeyValue(k, v)) @@ -196,24 +196,24 @@ object Aggregation { } } - def evaluatingParser(s: State, show: ShowConfig)(keys: Seq[KeyValue[_]])(implicit - display: Show[ScopedKey[_]] + def evaluatingParser(s: State, show: ShowConfig)(keys: Seq[KeyValue[?]])(implicit + display: Show[ScopedKey[?]] ): Parser[() => State] = { // to make the call sites clearer - def separate[L](in: Seq[KeyValue[_]])( - f: KeyValue[_] => Either[KeyValue[L], KeyValue[_]] - ): (Seq[KeyValue[L]], Seq[KeyValue[_]]) = + def separate[L](in: Seq[KeyValue[?]])( + f: KeyValue[?] => Either[KeyValue[L], KeyValue[?]] + ): (Seq[KeyValue[L]], Seq[KeyValue[?]]) = Util.separate(in)(f) val kvs = keys.toList if (kvs.isEmpty) failure("No such setting/task") else { - val (inputTasks, other) = separate[InputTask[_]](kvs) { + val (inputTasks, other) = separate[InputTask[?]](kvs) { case KeyValue(k, v: InputTask[_]) => Left(KeyValue(k, v)) case kv => Right(kv) } - val (tasks, settings) = separate[Task[_]](other) { + val (tasks, settings) = separate[Task[?]](other) { case KeyValue(k, v: Task[_]) => Left(KeyValue(k, v)) case kv => Right(kv) } @@ -280,7 +280,7 @@ object Aggregation { def reverseAggregatedKeys[T]( key: ScopedKey[T], - extra: BuildUtil[_], + extra: BuildUtil[?], mask: ScopeMask ): Seq[ScopedKey[T]] = projectAggregates(key.scope.project.toOption, extra, reverse = true) flatMap { ref => @@ -292,7 +292,7 @@ object Aggregation { def aggregatedKeys[T]( key: ScopedKey[T], - extra: BuildUtil[_], + extra: BuildUtil[?], mask: ScopeMask ): Seq[ScopedKey[T]] = projectAggregates(key.scope.project.toOption, extra, reverse = false) map { ref => @@ -301,7 +301,7 @@ object Aggregation { ScopedKey(resolved, key.key) } - def aggregationEnabled(key: ScopedKey[_], data: Settings[Scope]): Boolean = + def aggregationEnabled(key: ScopedKey[?], data: Settings[Scope]): Boolean = (Scope.fillTaskAxis(key.scope, key.key) / Keys.aggregate).get(data).getOrElse(true) private[sbt] val suppressShow = AttributeKey[Boolean]("suppress-aggregation-show", Int.MaxValue) diff --git a/main/src/main/scala/sbt/internal/BuildDef.scala b/main/src/main/scala/sbt/internal/BuildDef.scala index a2efed7d5..fb79ce20c 100644 --- a/main/src/main/scala/sbt/internal/BuildDef.scala +++ b/main/src/main/scala/sbt/internal/BuildDef.scala @@ -24,7 +24,7 @@ trait BuildDef { def projects: Seq[Project] = CompositeProject.expand(ReflectUtilities.allValsC(this, classOf[CompositeProject]).values.toSeq) // TODO: Should we grab the build core settings here or in a plugin? - def settings: Seq[Setting[_]] = Defaults.buildCore + def settings: Seq[Setting[?]] = Defaults.buildCore def buildLoaders: Seq[BuildLoader.Components] = Nil /** @@ -53,7 +53,7 @@ private[sbt] object BuildDef: Project(id, base).settings(defaultProjectSettings) def defaultAggregatedProject(id: String, base: File, agg: Seq[ProjectRef]): Project = - defaultProject(id, base).aggregate(agg: _*) + defaultProject(id, base).aggregate(agg*) private[sbt] def generatedRootSkipPublish( id: String, @@ -67,7 +67,7 @@ private[sbt] object BuildDef: publishLocal / skip := true, ) - private[sbt] def defaultProjectSettings: Seq[Setting[_]] = Seq( + private[sbt] def defaultProjectSettings: Seq[Setting[?]] = Seq( // TODO - Can we move this somewhere else? ordering of settings is causing this to get borked. // if the user has overridden the name, use the normal organization that is derived from the name. organization := { @@ -81,7 +81,7 @@ private[sbt] object BuildDef: ) def analyzed( - in: Seq[Attributed[_]], + in: Seq[Attributed[?]], converter: FileConverter ): Seq[xsbti.compile.CompileAnalysis] = in.flatMap(a => extractAnalysis(a.metadata, converter)) diff --git a/main/src/main/scala/sbt/internal/BuildStructure.scala b/main/src/main/scala/sbt/internal/BuildStructure.scala index fa2ece153..eb52c31a9 100644 --- a/main/src/main/scala/sbt/internal/BuildStructure.scala +++ b/main/src/main/scala/sbt/internal/BuildStructure.scala @@ -28,13 +28,13 @@ import xsbti.FileConverter final class BuildStructure( val units: Map[URI, LoadedBuildUnit], val root: URI, - val settings: Seq[Setting[_]], + val settings: Seq[Setting[?]], val data: Settings[Scope], val index: StructureIndex, val streams: State => Streams, val delegates: Scope => Seq[Scope], val scopeLocal: ScopeLocal, - private[sbt] val compiledMap: Map[ScopedKey[_], Def.Compiled[_]], + private[sbt] val compiledMap: Map[ScopedKey[?], Def.Compiled[?]], private[sbt] val converter: MappedFileConverter, ) { val extra: BuildUtil[ResolvedProject] = BuildUtil(root, units, index.keyIndex, data) @@ -70,8 +70,8 @@ final class BuildStructure( // information that is not original, but can be reconstructed from the rest of BuildStructure final class StructureIndex( - val keyMap: Map[String, AttributeKey[_]], - val taskToKey: Map[Task[_], ScopedKey[Task[_]]], + val keyMap: Map[String, AttributeKey[?]], + val taskToKey: Map[Task[?], ScopedKey[Task[?]]], val triggers: Triggers, val keyIndex: KeyIndex, val aggregateKeyIndex: KeyIndex, @@ -89,7 +89,7 @@ final class LoadedBuildUnit( val unit: BuildUnit, val defined: Map[String, ResolvedProject], val rootProjects: Seq[String], - val buildSettings: Seq[Setting[_]] + val buildSettings: Seq[Setting[?]] ) extends BuildUnitBase { /** @@ -283,23 +283,23 @@ final class PartBuild( val converter: MappedFileConverter, ) -sealed trait BuildUnitBase { def rootProjects: Seq[String]; def buildSettings: Seq[Setting[_]] } +sealed trait BuildUnitBase { def rootProjects: Seq[String]; def buildSettings: Seq[Setting[?]] } final class PartBuildUnit( val unit: BuildUnit, val defined: Map[String, Project], val rootProjects: Seq[String], - val buildSettings: Seq[Setting[_]] + val buildSettings: Seq[Setting[?]] ) extends BuildUnitBase { def resolve(f: Project => ResolvedProject): LoadedBuildUnit = new LoadedBuildUnit(unit, defined.view.mapValues(f).toMap, rootProjects, buildSettings) - def resolveRefs(f: ProjectReference => ProjectRef): LoadedBuildUnit = resolve(_ resolve f) + def resolveRefs(f: ProjectReference => ProjectRef): LoadedBuildUnit = resolve(_.resolve(f)) } object BuildStreams { - type Streams = sbt.std.Streams[ScopedKey[_]] + type Streams = sbt.std.Streams[ScopedKey[?]] final val GlobalPath = "_global" final val BuildUnitPath = "_build" @@ -311,10 +311,10 @@ object BuildStreams { root: URI, data: Settings[Scope] ): State => Streams = s => { - (s get Keys.stateStreams) getOrElse { + s.get(Keys.stateStreams).getOrElse { std.Streams( path(units, root, data)(_), - displayFull: ScopedKey[_] => String, + displayFull: ScopedKey[?] => String, LogManager.construct(data, s), { val factory = s.get(Keys.cacheStoreFactoryFactory).getOrElse(InMemoryCacheStore.factory(0)) @@ -325,14 +325,14 @@ object BuildStreams { } def path(units: Map[URI, LoadedBuildUnit], root: URI, data: Settings[Scope])( - scoped: ScopedKey[_] + scoped: ScopedKey[?] ): File = resolvePath(projectPath(units, root, scoped, data), nonProjectPath(scoped)) def resolvePath(base: File, components: Seq[String]): File = components.foldLeft(base)((b, p) => new File(b, p)) - def pathComponent[T](axis: ScopeAxis[T], scoped: ScopedKey[_], label: String)( + def pathComponent[T](axis: ScopeAxis[T], scoped: ScopedKey[?], label: String)( show: T => String ): String = axis match { @@ -385,7 +385,7 @@ object BuildStreams { def projectPath( units: Map[URI, LoadedBuildUnit], root: URI, - scoped: ScopedKey[_], + scoped: ScopedKey[?], data: Settings[Scope] ): File = scoped.scope.project match { diff --git a/main/src/main/scala/sbt/internal/ClassLoaders.scala b/main/src/main/scala/sbt/internal/ClassLoaders.scala index 1d7156b0d..9849c26c4 100644 --- a/main/src/main/scala/sbt/internal/ClassLoaders.scala +++ b/main/src/main/scala/sbt/internal/ClassLoaders.scala @@ -232,7 +232,7 @@ private[sbt] object ClassLoaders { // layer 3 val filteredSet = if (layerDependencies) allDependencies.toSet ++ si.libraryJars ++ scalaReflectJar - else Set(si.libraryJars ++ scalaReflectJar: _*) + else Set(si.libraryJars ++ scalaReflectJar*) val dynamicClasspath = cpFiles.filterNot(f => filteredSet(f) || scalaJarNames(f.getName)) dependencyLayer match { case dl: ReverseLookupClassLoaderHolder => diff --git a/main/src/main/scala/sbt/internal/ClasspathImpl.scala b/main/src/main/scala/sbt/internal/ClasspathImpl.scala index b277e8d32..a18d1c0fc 100644 --- a/main/src/main/scala/sbt/internal/ClasspathImpl.scala +++ b/main/src/main/scala/sbt/internal/ClasspathImpl.scala @@ -418,7 +418,7 @@ private[sbt] object ClasspathImpl { a => maps.foldLeft(Seq[B]()) { _ ++ _(a) }.distinct def parseList(s: String, allConfs: Seq[String]): Seq[String] = - (trim(s split ",") flatMap replaceWildcard(allConfs)).distinct + trim(s.split(",")).flatMap(replaceWildcard(allConfs)).distinct def replaceWildcard(allConfs: Seq[String])(conf: String): Seq[String] = conf match { case "" => Nil diff --git a/main/src/main/scala/sbt/internal/ConsoleProject.scala b/main/src/main/scala/sbt/internal/ConsoleProject.scala index 7d3708c87..c35ad8d8d 100644 --- a/main/src/main/scala/sbt/internal/ConsoleProject.scala +++ b/main/src/main/scala/sbt/internal/ConsoleProject.scala @@ -20,7 +20,7 @@ object ConsoleProject { def apply(state: State, extra: String, cleanupCommands: String = "", options: Seq[String] = Nil)( implicit log: Logger ): Unit = { - val extracted = Project extract state + val extracted = Project.extract(state) val cpImports = new Imports(extracted, state) val bindings = ("currentState" -> state) :: ("extracted" -> extracted) :: ("cpHelpers" -> cpImports) :: Nil diff --git a/main/src/main/scala/sbt/internal/Continuous.scala b/main/src/main/scala/sbt/internal/Continuous.scala index c6a43a5f6..a72035368 100644 --- a/main/src/main/scala/sbt/internal/Continuous.scala +++ b/main/src/main/scala/sbt/internal/Continuous.scala @@ -172,7 +172,7 @@ private[sbt] object Continuous extends DeprecatedContinuous { */ private def getConfig( state: State, - scopedKey: ScopedKey[_], + scopedKey: ScopedKey[?], compiledMap: CompiledMap, dynamicInputs: mutable.Set[DynamicInput], )(implicit extracted: Extracted, logger: Logger): Config = { @@ -217,13 +217,13 @@ private[sbt] object Continuous extends DeprecatedContinuous { // This is defined so we can assign a task key to a command to parse the WatchSettings. private val globalWatchSettingKey = taskKey[Unit]("Internal task key. Not actually used.").withRank(KeyRanks.Invisible) - private def parseCommand(command: String, state: State): Seq[ScopedKey[_]] = { + private def parseCommand(command: String, state: State): Seq[ScopedKey[?]] = { // Collect all of the scoped keys that are used to delegate the multi commands. These are // necessary to extract all of the transitive globs that we need to monitor during watch. // We have to add the <~ Parsers.any.* to ensure that we're able to extract the input key // from input tasks. - val scopedKeyParser: Parser[Seq[ScopedKey[_]]] = Act.aggregatedKeyParser(state) <~ Parsers.any.* - @tailrec def impl(current: String): Seq[ScopedKey[_]] = { + val scopedKeyParser: Parser[Seq[ScopedKey[?]]] = Act.aggregatedKeyParser(state) <~ Parsers.any.* + @tailrec def impl(current: String): Seq[ScopedKey[?]] = { Parser.parse(current, scopedKeyParser) match { case Right(scopedKeys: Seq[ScopedKey[_]]) => scopedKeys case Left(e) => @@ -927,7 +927,7 @@ private[sbt] object Continuous extends DeprecatedContinuous { * @param key the [[ScopedKey]] instance that sets the [[Scope]] for the settings we're extracting * @param extracted the [[Extracted]] instance for the build */ - private final class WatchSettings private[Continuous] (val key: ScopedKey[_])(implicit + private final class WatchSettings private[Continuous] (val key: ScopedKey[?])(implicit extracted: Extracted ) { val antiEntropy: FiniteDuration = @@ -989,14 +989,14 @@ private[sbt] object Continuous extends DeprecatedContinuous { end Config @nowarn - private def getStartMessage(key: ScopedKey[_])(implicit e: Extracted): StartMessage = Some { + private def getStartMessage(key: ScopedKey[?])(implicit e: Extracted): StartMessage = Some { lazy val default = key.get(watchStartMessage).getOrElse(Watch.defaultStartWatch) key.get(deprecatedWatchingMessage).map(Left(_)).getOrElse(Right(default)) } @nowarn private def getTriggerMessage( - key: ScopedKey[_] + key: ScopedKey[?] )(implicit e: Extracted): TriggerMessage = { lazy val default = key.get(watchTriggeredMessage).getOrElse(Watch.defaultOnTriggerMessage) @@ -1035,7 +1035,7 @@ private[sbt] object Continuous extends DeprecatedContinuous { } } - extension (scopedKey: ScopedKey[_]) { + extension (scopedKey: ScopedKey[?]) { /** * Gets the value for a setting key scoped to the wrapped [[ScopedKey]]. If the task axis is not diff --git a/main/src/main/scala/sbt/internal/CrossJava.scala b/main/src/main/scala/sbt/internal/CrossJava.scala index 68e2fbb8e..bfb2d854e 100644 --- a/main/src/main/scala/sbt/internal/CrossJava.scala +++ b/main/src/main/scala/sbt/internal/CrossJava.scala @@ -142,7 +142,7 @@ private[sbt] object CrossJava { val version: Parser[SwitchTarget] = (token( (StringBasic <~ "@").? ~ ((NatBasic) ~ ("." ~> NatBasic).*) - .examples(knownVersions: _*) ~ "!".? + .examples(knownVersions*) ~ "!".? ) || token(StringBasic)) .map { case Left(((vendor, (v1, vs)), bang)) => @@ -171,7 +171,7 @@ private[sbt] object CrossJava { proj: ResolvedReference ): Map[String, File] = { import extracted._ - ((proj / Keys.fullJavaHomes) get structure.data).get + (proj / Keys.fullJavaHomes).get(structure.data).get } private def getJavaHomesTyped( @@ -187,14 +187,14 @@ private[sbt] object CrossJava { ): Seq[String] = { import extracted._ import Keys._ - ((proj / crossJavaVersions) get structure.data).getOrElse(Nil) + (proj / crossJavaVersions).get(structure.data).getOrElse(Nil) } private def getCrossJavaHomes(extracted: Extracted, proj: ResolvedReference): Seq[File] = { import extracted._ import Keys._ - val fjh = ((proj / fullJavaHomes) get structure.data).get - ((proj / crossJavaVersions) get structure.data) map { jvs => + val fjh = (proj / fullJavaHomes).get(structure.data).get + (proj / crossJavaVersions).get(structure.data) map { jvs => jvs map { jv => lookupJavaHome(jv, fjh) } @@ -239,7 +239,7 @@ private[sbt] object CrossJava { ) } - val filterKeys: Set[AttributeKey[_]] = Set(javaHome).map(_.key) + val filterKeys: Set[AttributeKey[?]] = Set(javaHome).map(_.key) val projectsContains: Reference => Boolean = projects.map(_._1).toSet[Reference].contains(_) @@ -350,21 +350,21 @@ private[sbt] object CrossJava { } } - private val JavaCapturedSession = AttributeKey[Seq[Setting[_]]]("javaCrossCapturedSession") + private val JavaCapturedSession = AttributeKey[Seq[Setting[?]]]("javaCrossCapturedSession") private def captureCurrentSession(state: State, extracted: Extracted): State = { state.put(JavaCapturedSession, extracted.session.rawAppend) } def discoverJavaHomes: ListMap[String, File] = { - ListMap(JavaDiscoverConfig.configs flatMap { _.javaHomes } sortWith (versionOrder): _*) + ListMap(JavaDiscoverConfig.configs flatMap { _.javaHomes } sortWith (versionOrder)*) } sealed trait JavaDiscoverConf { def javaHomes: Vector[(String, File)] } - def versionOrder(left: (_, File), right: (_, File)): Boolean = + def versionOrder(left: (?, File), right: (?, File)): Boolean = versionOrder(left._2.getName, right._2.getName) // Sort version strings, considering 1.8.0 < 1.8.0_45 < 1.8.0_212 diff --git a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala index c5f19c50e..dbca7ca44 100644 --- a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala +++ b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala @@ -117,7 +117,7 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe final class ThreadJobHandle( override val id: Long, - override val spawningTask: ScopedKey[_], + override val spawningTask: ScopedKey[?], val logger: ManagedLogger, val workingDirectory: File, val job: BackgroundJob @@ -141,11 +141,11 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe // we use this if we deserialize a handle for a job that no longer exists private final class DeadHandle(override val id: Long, override val humanReadableName: String) extends AbstractJobHandle { - override val spawningTask: ScopedKey[_] = unknownTask + override val spawningTask: ScopedKey[?] = unknownTask } def doRunInBackground( - spawningTask: ScopedKey[_], + spawningTask: ScopedKey[?], state: State, start: (Logger, File) => BackgroundJob ): JobHandle = { @@ -167,13 +167,13 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe job } - override def runInBackground(spawningTask: ScopedKey[_], state: State)( + override def runInBackground(spawningTask: ScopedKey[?], state: State)( start: (Logger, File) => Unit ): JobHandle = { pool.run(this, spawningTask, state)(start) } - override private[sbt] def runInBackgroundWithLoader(spawningTask: ScopedKey[_], state: State)( + override private[sbt] def runInBackgroundWithLoader(spawningTask: ScopedKey[?], state: State)( start: (Logger, File) => (Option[ClassLoader], () => Unit) ): JobHandle = { pool.runWithLoader(this, spawningTask, state)(start) @@ -487,7 +487,7 @@ private[sbt] class BackgroundThreadPool extends java.io.Closeable { } } - def run(manager: AbstractBackgroundJobService, spawningTask: ScopedKey[_], state: State)( + def run(manager: AbstractBackgroundJobService, spawningTask: ScopedKey[?], state: State)( work: (Logger, File) => Unit ): JobHandle = { def start(logger: Logger, workingDir: File): BackgroundJob = { @@ -500,12 +500,12 @@ private[sbt] class BackgroundThreadPool extends java.io.Closeable { executor.execute(runnable) runnable } - manager.doRunInBackground(spawningTask, state, start _) + manager.doRunInBackground(spawningTask, state, start) } private[sbt] def runWithLoader( manager: AbstractBackgroundJobService, - spawningTask: ScopedKey[_], + spawningTask: ScopedKey[?], state: State )( getWork: (Logger, File) => (Option[ClassLoader], () => Unit) @@ -516,7 +516,7 @@ private[sbt] class BackgroundThreadPool extends java.io.Closeable { executor.execute(runnable) runnable } - manager.doRunInBackground(spawningTask, state, start _) + manager.doRunInBackground(spawningTask, state, start) } override def close(): Unit = { @@ -538,7 +538,7 @@ private[sbt] object DefaultBackgroundJobService { backgroundJobServices.values.forEach(_.shutdown()) backgroundJobServices.clear() } - private[sbt] lazy val backgroundJobServiceSetting: Setting[_] = + private[sbt] lazy val backgroundJobServiceSetting: Setting[?] = (GlobalScope / Keys.bgJobService) := { val path = (GlobalScope / sbt.Keys.bgJobServiceDirectory).value val useLog4J = (GlobalScope / Keys.useLog4J).value @@ -550,7 +550,7 @@ private[sbt] object DefaultBackgroundJobService { s } } - private[sbt] lazy val backgroundJobServiceSettings: Seq[Def.Setting[_]] = Def.settings( + private[sbt] lazy val backgroundJobServiceSettings: Seq[Def.Setting[?]] = Def.settings( (GlobalScope / Keys.bgJobServiceDirectory) := { sbt.Keys.appConfiguration.value.baseDirectory / "target" / "bg-jobs" }, diff --git a/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala b/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala index 2b92dc696..6d3baa19a 100644 --- a/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala +++ b/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala @@ -64,7 +64,7 @@ private[internal] trait DeprecatedContinuous { } private[sbt] object DeprecatedContinuous { - private[sbt] val taskDefinitions: Seq[Def.Setting[_]] = Seq( + private[sbt] val taskDefinitions: Seq[Def.Setting[?]] = Seq( /* sbt.Keys.watchTransitiveSources := sbt.Defaults.watchTransitiveSourcesTask.value, sbt.Keys.watch := sbt.Defaults.watchSetting.value, sbt.nio.Keys.watchTasks := Continuous.continuousTask.evaluated, */ diff --git a/main/src/main/scala/sbt/internal/FileChangesMacro.scala b/main/src/main/scala/sbt/internal/FileChangesMacro.scala index a71893f45..3fb58627e 100644 --- a/main/src/main/scala/sbt/internal/FileChangesMacro.scala +++ b/main/src/main/scala/sbt/internal/FileChangesMacro.scala @@ -66,7 +66,7 @@ object FileChangesMacro: mapKey = '{ outputFileStamps }, ) - def rescope[A](left: TaskKey[_], right: TaskKey[A]): TaskKey[A] = + def rescope[A](left: TaskKey[?], right: TaskKey[A]): TaskKey[A] = Scoped.scopedTask(left.scope.copy(task = Select(left.key)), right.key) def rescope[A](left: Scope, right: TaskKey[A]): TaskKey[A] = diff --git a/main/src/main/scala/sbt/internal/GlobalPlugin.scala b/main/src/main/scala/sbt/internal/GlobalPlugin.scala index 2f5ab96f2..3635b4c55 100644 --- a/main/src/main/scala/sbt/internal/GlobalPlugin.scala +++ b/main/src/main/scala/sbt/internal/GlobalPlugin.scala @@ -32,8 +32,8 @@ object GlobalPlugin { // constructs a sequence of settings that may be appended to a project's settings to // statically add the global plugin as a classpath dependency. // static here meaning that the relevant tasks for the global plugin have already been evaluated - def inject(gp: GlobalPluginData): Seq[Setting[_]] = - Seq[Setting[_]]( + def inject(gp: GlobalPluginData): Seq[Setting[?]] = + Seq[Setting[?]]( projectDescriptors ~= { _ ++ gp.descriptors }, projectDependencies ++= gp.projectID +: gp.dependencies, resolvers := { @@ -48,7 +48,7 @@ object GlobalPlugin { private def injectInternalClasspath( config: Configuration, cp: Def.Classpath, - ): Setting[_] = + ): Setting[?] = (config / internalDependencyClasspath) ~= { prev => (prev ++ cp).distinct } @@ -92,8 +92,8 @@ object GlobalPlugin { (prods ++ intcp).distinct )(updateReport.value) } - val resolvedTaskInit = taskInit mapReferenced Project.mapScope(Scope replaceThis p) - val task = resolvedTaskInit evaluate data + val resolvedTaskInit = taskInit.mapReferenced(Project.mapScope(Scope.replaceThis(p))) + val task = resolvedTaskInit.evaluate(data) val roots = resolvedTaskInit.dependencies evaluate(state, structure, task, roots) } @@ -101,7 +101,7 @@ object GlobalPlugin { state: State, structure: BuildStructure, t: Task[T], - roots: Seq[ScopedKey[_]] + roots: Seq[ScopedKey[?]] ): (State, T) = { import EvaluateTask._ withStreams(structure, state) { str => @@ -134,6 +134,6 @@ final case class GlobalPluginData( final case class GlobalPlugin( data: GlobalPluginData, structure: BuildStructure, - inject: Seq[Setting[_]], + inject: Seq[Setting[?]], base: File ) diff --git a/main/src/main/scala/sbt/internal/GroupedAutoPlugins.scala b/main/src/main/scala/sbt/internal/GroupedAutoPlugins.scala index ca9c77ec7..13b2c988f 100644 --- a/main/src/main/scala/sbt/internal/GroupedAutoPlugins.scala +++ b/main/src/main/scala/sbt/internal/GroupedAutoPlugins.scala @@ -16,8 +16,8 @@ private[sbt] final class GroupedAutoPlugins( val all: Seq[AutoPlugin], val byBuild: Map[URI, Seq[AutoPlugin]] ) { - def globalSettings: Seq[Setting[_]] = all.flatMap(_.globalSettings) - def buildSettings(uri: URI): Seq[Setting[_]] = + def globalSettings: Seq[Setting[?]] = all.flatMap(_.globalSettings) + def buildSettings(uri: URI): Seq[Setting[?]] = byBuild.getOrElse(uri, Nil).flatMap(_.buildSettings) } diff --git a/main/src/main/scala/sbt/internal/IncrementalTest.scala b/main/src/main/scala/sbt/internal/IncrementalTest.scala index a9735acbf..d0e20fa26 100644 --- a/main/src/main/scala/sbt/internal/IncrementalTest.scala +++ b/main/src/main/scala/sbt/internal/IncrementalTest.scala @@ -57,7 +57,7 @@ object IncrementalTest: stamper.transitiveStamp(name, extra ++ rds ++ opts) match case Some(ts) => Seq(name -> ts) case None => Nil - ): _*) + )*) } def extraTestDigestsTask: Initialize[Task[Seq[Digest]]] = Def.cachedTask { @@ -159,8 +159,8 @@ class ClassStamper( * @param extraHashes additional information to include into the returning digest */ private[sbt] def transitiveStamp(className: String, extaHashes: Seq[Digest]): Option[Digest] = - val digests = SortedSet(analyses.flatMap(internalStamp(className, _, Set.empty)): _*) - if digests.nonEmpty then Some(Digest.sha256Hash(digests.toSeq ++ extaHashes: _*)) + val digests = SortedSet(analyses.flatMap(internalStamp(className, _, Set.empty))*) + if digests.nonEmpty then Some(Digest.sha256Hash(digests.toSeq ++ extaHashes*)) else None private def internalStamp( @@ -206,7 +206,7 @@ class ClassStamper( // .map: analyzed => // 0L // analyzed.??? we need a hash here val xs = SortedSet( - (internalDeps union internalJarDeps union externalDeps union classDigests).toSeq: _* + (internalDeps union internalJarDeps union externalDeps union classDigests).toSeq* ) if xs.nonEmpty then stamps(className) = xs else () diff --git a/main/src/main/scala/sbt/internal/Inspect.scala b/main/src/main/scala/sbt/internal/Inspect.scala index 8cc4cd32e..76b1a5072 100644 --- a/main/src/main/scala/sbt/internal/Inspect.scala +++ b/main/src/main/scala/sbt/internal/Inspect.scala @@ -43,13 +43,12 @@ object Inspect { token(Space ~> (default | tree | actual | uses | definitions)) ?? Details(false) } - def allKeyParser(s: State): Parser[AttributeKey[_]] = { + def allKeyParser(s: State): Parser[AttributeKey[?]] = { val keyMap = Project.structure(s).index.keyMap - token(Space ~> (ID !!! "Expected key" examples keyMap.keySet)) flatMap { key => + token(Space ~> ((ID !!! "Expected key").examples(keyMap.keySet))).flatMap: key => Act.getKey(keyMap, key, idFun) - } } - val spacedKeyParser: State => Parser[ScopedKey[_]] = (s: State) => + val spacedKeyParser: State => Parser[ScopedKey[?]] = (s: State) => Act.requireSession(s, token(Space) ~> Act.scopedKeyParser(s)) def keyHandler(s: State): Mode => Parser[() => String] = { @@ -84,7 +83,7 @@ object Inspect { }) } - def keyOutput(s: State, option: Mode, sk: Def.ScopedKey[_]): String = { + def keyOutput(s: State, option: Mode, sk: Def.ScopedKey[?]): String = { val extracted = Project.extract(s) import extracted._ option match { diff --git a/main/src/main/scala/sbt/internal/IvyConsole.scala b/main/src/main/scala/sbt/internal/IvyConsole.scala index c32b8c99a..9b98e86b8 100644 --- a/main/src/main/scala/sbt/internal/IvyConsole.scala +++ b/main/src/main/scala/sbt/internal/IvyConsole.scala @@ -9,7 +9,6 @@ package sbt package internal -import sbt.internal.util.Attributed import sbt.util.{ Level, Logger } import sbt.librarymanagement.{ @@ -30,6 +29,7 @@ import sbt.ProjectExtra.{ extract, setProject } import sbt.SlashSyntax0.given import sbt.io.IO +import xsbti.HashedVirtualFileRef object IvyConsole { final val Name = "ivy-console" @@ -49,13 +49,13 @@ object IvyConsole { val extracted = Project.extract(session, structure) import extracted._ - val depSettings: Seq[Setting[_]] = Seq( + val depSettings: Seq[Setting[?]] = Seq( libraryDependencies ++= managed.reverse, resolvers ++= repos.reverse.toVector, Compile / unmanagedJars ++= { val converter = fileConverter.value val u = unmanaged.reverse.map(_.toPath).map(converter.toVirtualFile) - Attributed.blankSeq(u) + u: Seq[HashedVirtualFileRef] }, Global / logLevel := Level.Warn, Global / showSuccess := false @@ -81,9 +81,9 @@ object IvyConsole { args.foldLeft(Dependencies(Nil, Nil, Nil))(parseArgument(log)) def parseArgument(log: Logger)(acc: Dependencies, arg: String): Dependencies = arg match { - case _ if arg contains " at " => acc.copy(resolvers = parseResolver(arg) +: acc.resolvers) - case _ if arg endsWith ".jar" => acc.copy(unmanaged = new File(arg) +: acc.unmanaged) - case _ => acc.copy(managed = parseManaged(arg, log) ++ acc.managed) + case _ if arg.contains(" at ") => acc.copy(resolvers = parseResolver(arg) +: acc.resolvers) + case _ if arg.endsWith(".jar") => acc.copy(unmanaged = new File(arg) +: acc.unmanaged) + case _ => acc.copy(managed = parseManaged(arg, log) ++ acc.managed) } private def parseResolver(arg: String): MavenRepository = { diff --git a/main/src/main/scala/sbt/internal/JarClassPath.scala b/main/src/main/scala/sbt/internal/JarClassPath.scala index ae0c46619..8837d86e4 100644 --- a/main/src/main/scala/sbt/internal/JarClassPath.scala +++ b/main/src/main/scala/sbt/internal/JarClassPath.scala @@ -29,7 +29,7 @@ private[internal] object JarClassPath { } } private[internal] final class JarClassPath(val jars: Seq[File]) { - private def isSnapshot(file: File): Boolean = file.getName contains "-SNAPSHOT" + private def isSnapshot(file: File): Boolean = file.getName.contains("-SNAPSHOT") private val jarSet = jars.toSet val (snapshotJars, regularJars) = jars.partition(isSnapshot) private val snapshots = snapshotJars.map(new JarClassPath.Snapshot(_)) diff --git a/main/src/main/scala/sbt/internal/KeyIndex.scala b/main/src/main/scala/sbt/internal/KeyIndex.scala index eff64d8ab..4c6be3ef4 100644 --- a/main/src/main/scala/sbt/internal/KeyIndex.scala +++ b/main/src/main/scala/sbt/internal/KeyIndex.scala @@ -20,17 +20,17 @@ object KeyIndex { def empty: ExtendableKeyIndex = new KeyIndex0(emptyBuildIndex) def apply( - known: Iterable[ScopedKey[_]], + known: Iterable[ScopedKey[?]], projects: Map[URI, Set[String]], configurations: Map[String, Seq[Configuration]] ): ExtendableKeyIndex = { import scala.collection.parallel.CollectionConverters.* - known.par.foldLeft(base(projects, configurations)) { _ add _ } + known.par.foldLeft(base(projects, configurations)) { _.add(_) } } def aggregate( - known: Iterable[ScopedKey[_]], - extra: BuildUtil[_], + known: Iterable[ScopedKey[?]], + extra: BuildUtil[?], projects: Map[URI, Set[String]], configurations: Map[String, Seq[Configuration]] ): ExtendableKeyIndex = { @@ -50,7 +50,7 @@ object KeyIndex { } toAggregate.foldLeft(base(projects, configurations)) { case (index, Nil) => index - case (index, keys) => keys.foldLeft(index)(_ add _) + case (index, keys) => keys.foldLeft(index)(_.add(_)) } } @@ -74,7 +74,7 @@ object KeyIndex { def combine(indices: Seq[KeyIndex]): KeyIndex = new KeyIndex { def buildURIs = concat(_.buildURIs) def projects(uri: URI) = concat(_.projects(uri)) - def exists(project: Option[ResolvedReference]): Boolean = indices.exists(_ exists project) + def exists(project: Option[ResolvedReference]): Boolean = indices.exists(_.exists(project)) def configs(proj: Option[ResolvedReference]) = concat(_.configs(proj)) private[sbt] def configIdents(proj: Option[ResolvedReference]) = concat(_.configIdents(proj)) private[sbt] def fromConfigIdent(proj: Option[ResolvedReference])(configIdent: String): String = @@ -87,7 +87,7 @@ object KeyIndex { concat(_.tasks(proj, conf, key)) def keys(proj: Option[ResolvedReference]) = concat(_.keys(proj)) def keys(proj: Option[ResolvedReference], conf: Option[String]) = concat(_.keys(proj, conf)) - def keys(proj: Option[ResolvedReference], conf: Option[String], task: Option[AttributeKey[_]]) = + def keys(proj: Option[ResolvedReference], conf: Option[String], task: Option[AttributeKey[?]]) = concat(_.keys(proj, conf, task)) def concat[T](f: KeyIndex => Set[T]): Set[T] = indices.foldLeft(Set.empty[T])((s, k) => s ++ f(k)) @@ -109,41 +109,41 @@ trait KeyIndex { def isEmpty( proj: Option[ResolvedReference], conf: Option[String], - task: Option[AttributeKey[_]] + task: Option[AttributeKey[?]] ): Boolean = keys(proj, conf, task).isEmpty def buildURIs: Set[URI] def projects(uri: URI): Set[String] def exists(project: Option[ResolvedReference]): Boolean def configs(proj: Option[ResolvedReference]): Set[String] - def tasks(proj: Option[ResolvedReference], conf: Option[String]): Set[AttributeKey[_]] + def tasks(proj: Option[ResolvedReference], conf: Option[String]): Set[AttributeKey[?]] def tasks( proj: Option[ResolvedReference], conf: Option[String], key: String - ): Set[AttributeKey[_]] + ): Set[AttributeKey[?]] def keys(proj: Option[ResolvedReference]): Set[String] def keys(proj: Option[ResolvedReference], conf: Option[String]): Set[String] def keys( proj: Option[ResolvedReference], conf: Option[String], - task: Option[AttributeKey[_]] + task: Option[AttributeKey[?]] ): Set[String] private[sbt] def configIdents(project: Option[ResolvedReference]): Set[String] private[sbt] def fromConfigIdent(proj: Option[ResolvedReference])(configIdent: String): String } trait ExtendableKeyIndex extends KeyIndex { - def add(scoped: ScopedKey[_]): ExtendableKeyIndex - def addAggregated(scoped: ScopedKey[_], extra: BuildUtil[_]): ExtendableKeyIndex + def add(scoped: ScopedKey[?]): ExtendableKeyIndex + def addAggregated(scoped: ScopedKey[?], extra: BuildUtil[?]): ExtendableKeyIndex } // task axis <-> key -private[sbt] final class AKeyIndex(val data: Relation[Option[AttributeKey[_]], String]) { - def add(task: Option[AttributeKey[_]], key: AttributeKey[_]): AKeyIndex = +private[sbt] final class AKeyIndex(val data: Relation[Option[AttributeKey[?]], String]) { + def add(task: Option[AttributeKey[?]], key: AttributeKey[?]): AKeyIndex = new AKeyIndex(data + (task, key.label)) - def keys(task: Option[AttributeKey[_]]): Set[String] = data.forward(task) + def keys(task: Option[AttributeKey[?]]): Set[String] = data.forward(task) def allKeys: Set[String] = data._2s.toSet - def tasks: Set[AttributeKey[_]] = data._1s.flatten.toSet - def tasks(key: String): Set[AttributeKey[_]] = data.reverse(key).flatten + def tasks: Set[AttributeKey[?]] = data._1s.flatten.toSet + def tasks(key: String): Set[AttributeKey[?]] = data.reverse(key).flatten } private[sbt] case class IdentifiableConfig(name: String, ident: Option[String]) @@ -162,8 +162,8 @@ private[sbt] final class ConfigIndex( ) { def add( config: Option[IdentifiableConfig], - task: Option[AttributeKey[_]], - key: AttributeKey[_] + task: Option[AttributeKey[?]], + key: AttributeKey[?] ): ConfigIndex = { config match { case Some(c) => addKeyWithConfig(c, task, key) @@ -173,8 +173,8 @@ private[sbt] final class ConfigIndex( def addKeyWithConfig( config: IdentifiableConfig, - task: Option[AttributeKey[_]], - key: AttributeKey[_] + task: Option[AttributeKey[?]], + key: AttributeKey[?] ): ConfigIndex = { val keyIndex = data.getOrElse(config.name, emptyAKeyIndex) val configIdent = config.ident.getOrElse(Scope.guessConfigIdent(config.name)) @@ -185,7 +185,7 @@ private[sbt] final class ConfigIndex( ) } - def addKeyWithoutConfig(task: Option[AttributeKey[_]], key: AttributeKey[_]): ConfigIndex = { + def addKeyWithoutConfig(task: Option[AttributeKey[?]], key: AttributeKey[?]): ConfigIndex = { new ConfigIndex(data, configIdentToName, noConfigKeys.add(task, key)) } @@ -208,8 +208,8 @@ private[sbt] final class ProjectIndex(val data: Map[Option[String], ConfigIndex] def add( id: Option[String], config: Option[IdentifiableConfig], - task: Option[AttributeKey[_]], - key: AttributeKey[_] + task: Option[AttributeKey[?]], + key: AttributeKey[?] ): ProjectIndex = new ProjectIndex(data updated (id, confIndex(id).add(config, task, key))) def confIndex(id: Option[String]): ConfigIndex = getOr(data, id, emptyConfigIndex) @@ -220,8 +220,8 @@ private[sbt] final class BuildIndex(val data: Map[Option[URI], ProjectIndex]) { build: Option[URI], project: Option[String], config: Option[IdentifiableConfig], - task: Option[AttributeKey[_]], - key: AttributeKey[_] + task: Option[AttributeKey[?]], + key: AttributeKey[?] ): BuildIndex = new BuildIndex(data updated (build, projectIndex(build).add(project, config, task, key))) def projectIndex(build: Option[URI]): ProjectIndex = getOr(data, build, emptyProjectIndex) @@ -242,13 +242,13 @@ private[sbt] final class KeyIndex0(val data: BuildIndex) extends ExtendableKeyIn private[sbt] def fromConfigIdent(proj: Option[ResolvedReference])(configIdent: String): String = confIndex(proj).fromConfigIdent(configIdent) - def tasks(proj: Option[ResolvedReference], conf: Option[String]): Set[AttributeKey[_]] = + def tasks(proj: Option[ResolvedReference], conf: Option[String]): Set[AttributeKey[?]] = keyIndex(proj, conf).tasks def tasks( proj: Option[ResolvedReference], conf: Option[String], key: String - ): Set[AttributeKey[_]] = keyIndex(proj, conf).tasks(key) + ): Set[AttributeKey[?]] = keyIndex(proj, conf).tasks(key) def keys(proj: Option[ResolvedReference]): Set[String] = optConfigs(proj).foldLeft(Set.empty[String]) { (s, c) => s ++ keys(proj, c) @@ -258,7 +258,7 @@ private[sbt] final class KeyIndex0(val data: BuildIndex) extends ExtendableKeyIn def keys( proj: Option[ResolvedReference], conf: Option[String], - task: Option[AttributeKey[_]] + task: Option[AttributeKey[?]] ): Set[String] = keyIndex(proj, conf).keys(task) def keyIndex(proj: Option[ResolvedReference], conf: Option[String]): AKeyIndex = @@ -276,15 +276,15 @@ private[sbt] final class KeyIndex0(val data: BuildIndex) extends ExtendableKeyIn private def optConfigs(project: Option[ResolvedReference]): Seq[Option[String]] = None +: (configs(project).toSeq.map(some[String])) - def addAggregated(scoped: ScopedKey[_], extra: BuildUtil[_]): ExtendableKeyIndex = + def addAggregated(scoped: ScopedKey[?], extra: BuildUtil[?]): ExtendableKeyIndex = if (validID(scoped.key.label)) { val aggregateProjects = Aggregation.aggregate(scoped, ScopeMask(), extra, reverse = true) - aggregateProjects.foldLeft(this: ExtendableKeyIndex)(_ add _) + aggregateProjects.foldLeft(this: ExtendableKeyIndex)(_.add(_)) } else this - def add(scoped: ScopedKey[_]): ExtendableKeyIndex = + def add(scoped: ScopedKey[?]): ExtendableKeyIndex = if (validID(scoped.key.label)) add0(scoped) else this - private def add0(scoped: ScopedKey[_]): ExtendableKeyIndex = { + private def add0(scoped: ScopedKey[?]): ExtendableKeyIndex = { val (build, project) = parts(scoped.scope.project.toOption) add1(build, project, scoped.scope.config, scoped.scope.task, scoped.key) } @@ -292,8 +292,8 @@ private[sbt] final class KeyIndex0(val data: BuildIndex) extends ExtendableKeyIn uri: Option[URI], id: Option[String], config: ScopeAxis[ConfigKey], - task: ScopeAxis[AttributeKey[_]], - key: AttributeKey[_] + task: ScopeAxis[AttributeKey[?]], + key: AttributeKey[?] ): ExtendableKeyIndex = { val keyConfig = config.toOption.map(c => IdentifiableConfig(c.name, None)) new KeyIndex0(data.add(uri, id, keyConfig, task.toOption, key)) diff --git a/main/src/main/scala/sbt/internal/LibraryManagement.scala b/main/src/main/scala/sbt/internal/LibraryManagement.scala index df1b40836..b96974548 100644 --- a/main/src/main/scala/sbt/internal/LibraryManagement.scala +++ b/main/src/main/scala/sbt/internal/LibraryManagement.scala @@ -260,8 +260,8 @@ private[sbt] object LibraryManagement { Keys.TaskStreams, UpdateConfiguration, Option[Level.Value], - Seq[ScopedKey[_]], - ScopedKey[_], + Seq[ScopedKey[?]], + ScopedKey[?], Option[FiniteDuration], IvySbt#Module, String, diff --git a/main/src/main/scala/sbt/internal/LintUnused.scala b/main/src/main/scala/sbt/internal/LintUnused.scala index e78ec6854..ed7336a93 100644 --- a/main/src/main/scala/sbt/internal/LintUnused.scala +++ b/main/src/main/scala/sbt/internal/LintUnused.scala @@ -18,7 +18,7 @@ import sbt.SlashSyntax0.given import sbt.Def._ object LintUnused { - lazy val lintSettings: Seq[Setting[_]] = Seq( + lazy val lintSettings: Seq[Setting[?]] = Seq( lintIncludeFilter := { val includes = includeLintKeys.value.map(_.scopedKey.key.label) keyName => includes(keyName) @@ -94,7 +94,7 @@ object LintUnused { } def lintResultLines( - result: Seq[(ScopedKey[_], String, Vector[SourcePosition])] + result: Seq[(ScopedKey[?], String, Vector[SourcePosition])] ): Vector[String] = { import scala.collection.mutable.ListBuffer val buffer = ListBuffer.empty[String] @@ -127,14 +127,14 @@ object LintUnused { state: State, includeKeys: String => Boolean, excludeKeys: String => Boolean - ): Seq[(ScopedKey[_], String, Vector[SourcePosition])] = { + ): Seq[(ScopedKey[?], String, Vector[SourcePosition])] = { val extracted = Project.extract(state) val structure = extracted.structure val display = Def.showShortKey(None) // extracted.showKey val comp = structure.compiledMap val cMap = Def.flattenLocals(comp) - val used: Set[ScopedKey[_]] = cMap.values.flatMap(_.dependencies).toSet - val unused: Seq[ScopedKey[_]] = cMap.keys.filter(!used.contains(_)).toSeq + val used: Set[ScopedKey[?]] = cMap.values.flatMap(_.dependencies).toSet + val unused: Seq[ScopedKey[?]] = cMap.keys.filter(!used.contains(_)).toSeq val withDefinedAts: Seq[UnusedKey] = unused map { u => val definingScope = structure.data.definingScope(u.scope, u.key) val definingScoped = definingScope match { @@ -173,12 +173,12 @@ object LintUnused { } private case class UnusedKey( - scoped: ScopedKey[_], + scoped: ScopedKey[?], positions: Vector[SourcePosition], - data: Option[ScopedKeyData[_]] + data: Option[ScopedKeyData[?]] ) - private def definedAtString(settings: Vector[Setting[_]]): Vector[SourcePosition] = { + private def definedAtString(settings: Vector[Setting[?]]): Vector[SourcePosition] = { settings flatMap { setting => setting.pos match { case NoPosition => Vector.empty diff --git a/main/src/main/scala/sbt/internal/Load.scala b/main/src/main/scala/sbt/internal/Load.scala index c2b16d0b2..7cf3bb2c2 100755 --- a/main/src/main/scala/sbt/internal/Load.scala +++ b/main/src/main/scala/sbt/internal/Load.scala @@ -113,7 +113,7 @@ private[sbt] object Load { javaHome = None, scalac ) - val evalPluginDef: (BuildStructure, State) => PluginData = EvaluateTask.evalPluginDef _ + val evalPluginDef: (BuildStructure, State) => PluginData = EvaluateTask.evalPluginDef val delegates = defaultDelegates val pluginMgmt = PluginManagement(loader) val inject = InjectSettings(injectGlobal(state), Nil, const(Nil)) @@ -143,7 +143,7 @@ private[sbt] object Load { case _: NoSuchMethodError => None } - def injectGlobal(state: State): Seq[Setting[_]] = + def injectGlobal(state: State): Seq[Setting[?]] = ((GlobalScope / appConfiguration) :== state.configuration) +: LogManager.settingsLogger(state) +: EvaluateTask.injectSettings @@ -168,7 +168,7 @@ private[sbt] object Load { files: Seq[VirtualFile], config: LoadBuildConfiguration ): LoadBuildConfiguration = - val compiled: ClassLoader => Seq[Setting[_]] = + val compiled: ClassLoader => Seq[Setting[?]] = if (files.isEmpty || base == globalBase) const(Nil) else buildGlobalSettings(globalBase, files, config) config.copy(injectSettings = config.injectSettings.copy(projectLoaded = compiled)) @@ -177,7 +177,7 @@ private[sbt] object Load { base: File, files: Seq[VirtualFile], config: LoadBuildConfiguration, - ): ClassLoader => Seq[Setting[_]] = { + ): ClassLoader => Seq[Setting[?]] = { val converter = config.converter val eval = mkEval( classpath = data(config.globalPluginClasspath).map(converter.toPath), @@ -332,8 +332,8 @@ private[sbt] object Load { // 2. the defining key is stored on constructed tasks: used for error reporting among other things // 3. resolvedScoped is replaced with the defining key as a value // Note: this must be idempotent. - def finalTransforms(ss: Seq[Setting[_]]): Seq[Setting[_]] = { - def mapSpecial(to: ScopedKey[_]): [a] => ScopedKey[a] => ScopedKey[a] = + def finalTransforms(ss: Seq[Setting[?]]): Seq[Setting[?]] = { + def mapSpecial(to: ScopedKey[?]): [a] => ScopedKey[a] => ScopedKey[a] = [a] => (key: ScopedKey[a]) => if key.key == streams.key then @@ -346,24 +346,26 @@ private[sbt] object Load { case ik: InputTask[t] => ik.mapTask(tk => setDefinitionKey(tk, key)).asInstanceOf[T] case _ => value } - def setResolved(defining: ScopedKey[_]): [a] => ScopedKey[a] => Option[a] = + def setResolved(defining: ScopedKey[?]): [a] => ScopedKey[a] => Option[a] = [a] => (key: ScopedKey[a]) => key.key match case resolvedScoped.key => Some(defining.asInstanceOf[a]) case _ => None ss.map(s => - s mapConstant setResolved(s.key) mapReferenced mapSpecial(s.key) mapInit setDefining + s.mapConstant(setResolved(s.key)) + .mapReferenced(mapSpecial(s.key)) + .mapInit(setDefining) ) } - def setDefinitionKey[T](tk: Task[T], key: ScopedKey[_]): Task[T] = + def setDefinitionKey[T](tk: Task[T], key: ScopedKey[?]): Task[T] = if (isDummy(tk)) tk else Task(tk.info.set(Keys.taskDefinitionKey, key), tk.work) def structureIndex( data: Settings[Scope], - settings: Seq[Setting[_]], - extra: KeyIndex => BuildUtil[_], + settings: Seq[Setting[?]], + extra: KeyIndex => BuildUtil[?], projects: Map[URI, LoadedBuildUnit] ): StructureIndex = { val keys = Index.allKeys(settings) @@ -384,8 +386,8 @@ private[sbt] object Load { } // Reevaluates settings after modifying them. Does not recompile or reload any build components. - def reapply(newSettings: Seq[Setting[_]], structure: BuildStructure)(implicit - display: Show[ScopedKey[_]] + def reapply(newSettings: Seq[Setting[?]], structure: BuildStructure)(implicit + display: Show[ScopedKey[?]] ): BuildStructure = { val transformed = finalTransforms(newSettings) val (cMap, newData) = @@ -409,10 +411,10 @@ private[sbt] object Load { @deprecated("No longer used. For binary compatibility", "1.2.1") def reapply( - newSettings: Seq[Setting[_]], + newSettings: Seq[Setting[?]], structure: BuildStructure, log: Logger - )(implicit display: Show[ScopedKey[_]]): BuildStructure = { + )(implicit display: Show[ScopedKey[?]]): BuildStructure = { reapply(newSettings, structure) } @@ -420,7 +422,7 @@ private[sbt] object Load { loaded: LoadedBuild, rootProject: URI => String, injectSettings: InjectSettings - ): Seq[Setting[_]] = { + ): Seq[Setting[?]] = { (((GlobalScope / loadedBuild) :== loaded) +: transformProjectOnly(loaded.root, rootProject, injectSettings.global)) ++ inScope(GlobalScope)(loaded.autos.globalSettings) ++ @@ -428,10 +430,10 @@ private[sbt] object Load { val pluginBuildSettings = loaded.autos.buildSettings(uri) val projectSettings = build.defined flatMap { case (id, project) => val ref = ProjectRef(uri, id) - val defineConfig: Seq[Setting[_]] = + val defineConfig: Seq[Setting[?]] = for (c <- project.configurations) yield ((ref / ConfigKey(c.name) / configuration) :== c) - val builtin: Seq[Setting[_]] = + val builtin: Seq[Setting[?]] = (thisProject :== project) +: (thisProjectRef :== ref) +: defineConfig val settings = builtin ++ injectSettings.project ++ project.settings // map This to thisScope, Select(p) to mapRef(uri, rootProject, p) @@ -448,16 +450,16 @@ private[sbt] object Load { def transformProjectOnly( uri: URI, rootProject: URI => String, - settings: Seq[Setting[_]] - ): Seq[Setting[_]] = + settings: Seq[Setting[?]] + ): Seq[Setting[?]] = Project.transform(Scope.resolveProject(uri, rootProject), settings) def transformSettings( thisScope: Scope, uri: URI, rootProject: URI => String, - settings: Seq[Setting[_]] - ): Seq[Setting[_]] = { + settings: Seq[Setting[?]] + ): Seq[Setting[?]] = { val transformed = Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) Settings.inject(transformed) } @@ -603,7 +605,7 @@ private[sbt] object Load { (partBuildUnit, externals) } - def buildSettings(unit: BuildUnit): Seq[Setting[_]] = { + def buildSettings(unit: BuildUnit): Seq[Setting[?]] = { val buildScope = GlobalScope.copy(project = Select(BuildRef(unit.uri))) val resolve = Scope.resolveBuildScope(buildScope, unit.uri) Project.transform(resolve, unit.definitions.builds.flatMap(_.settings)) @@ -935,7 +937,7 @@ private[sbt] object Load { plugins: LoadedPlugins, eval: () => Eval, machineWideUserSettings: InjectSettings, - commonSettings: Seq[Setting[_]], + commonSettings: Seq[Setting[?]], acc: Seq[Project], memoSettings: mutable.Map[VirtualFile, LoadedSbtFile], log: Logger, @@ -951,7 +953,7 @@ private[sbt] object Load { newProjects: Seq[Project], acc: Seq[Project], generated: Seq[Path], - commonSettings0: Seq[Setting[_]], + commonSettings0: Seq[Setting[?]], ): LoadedProjects = loadTransitive( newProjects, @@ -1084,7 +1086,7 @@ private[sbt] object Load { ) val existingIds = otherProjects.projects.map(_.id) val refs = existingIds.map(id => ProjectRef(buildUri, id)) - (root.aggregate(refs: _*), false, Nil, otherProjects) + (root.aggregate(refs*), false, Nil, otherProjects) val (finalRoot, projectLevelExtra) = timed(s"Load.loadTransitive: finalizeProject($root)", log) { finalizeProject(root, files, extraFiles, expand) @@ -1141,7 +1143,7 @@ private[sbt] object Load { p: Project, projectPlugins: Seq[AutoPlugin], loadedPlugins: LoadedPlugins, - commonSettings: Seq[Setting[_]], + commonSettings: Seq[Setting[?]], machineWideUserSettings: InjectSettings, memoSettings: mutable.Map[VirtualFile, LoadedSbtFile], extraSbtFiles: Seq[VirtualFile], @@ -1155,30 +1157,30 @@ private[sbt] object Load { // 3. Use AddSettings instance to order all Setting[_]s appropriately // Settings are ordered as: // AutoPlugin settings, common settings, machine-wide settings + project.settings(...) - def allAutoPluginSettings: Seq[Setting[_]] = { + def allAutoPluginSettings: Seq[Setting[?]] = { // Filter the AutoPlugin settings we included based on which ones are // intended in the AddSettings.AutoPlugins filter. def autoPluginSettings(f: AutoPlugins) = projectPlugins.withFilter(f.include).flatMap(_.projectSettings) // Expand the AddSettings instance into a real Seq[Setting[_]] we'll use on the project - def expandPluginSettings(auto: AddSettings): Seq[Setting[_]] = + def expandPluginSettings(auto: AddSettings): Seq[Setting[?]] = auto match case p: AutoPlugins => autoPluginSettings(p) case q: Sequence => - q.sequence.foldLeft(Seq.empty[Setting[_]]) { (b, add) => + q.sequence.foldLeft(Seq.empty[Setting[?]]) { (b, add) => b ++ expandPluginSettings(add) } case _ => Nil expandPluginSettings(auto) } - def allProjectSettings: Seq[Setting[_]] = + def allProjectSettings: Seq[Setting[?]] = // Expand the AddSettings instance into a real Seq[Setting[_]] we'll use on the project - def expandSettings(auto: AddSettings): Seq[Setting[_]] = + def expandSettings(auto: AddSettings): Seq[Setting[?]] = auto match case User => machineWideUserSettings.cachedProjectLoaded(loadedPlugins.loader) case BuildScalaFiles => p.settings case q: Sequence => - q.sequence.foldLeft(Seq.empty[Setting[_]]) { (b, add) => + q.sequence.foldLeft(Seq.empty[Setting[?]]) { (b, add) => b ++ expandSettings(add) } case _ => Nil @@ -1189,7 +1191,7 @@ private[sbt] object Load { p.copy(settings = allAutoPluginSettings ++ commonSettings ++ allProjectSettings) .setCommonSettings(commonSettings) .setAutoPlugins(projectPlugins) - .prefixConfigs(autoConfigs: _*) + .prefixConfigs(autoConfigs*) } private def expandCommonSettingsPerBase( @@ -1198,25 +1200,25 @@ private[sbt] object Load { extraSbtFiles: Seq[VirtualFile], converter: MappedFileConverter, log: Logger - ): Seq[Setting[_]] = + ): Seq[Setting[?]] = val defaultSbtFiles = configurationSources(directory) .map(_.getAbsoluteFile().toPath()) .map(converter.toVirtualFile) .toVector val sbtFiles = defaultSbtFiles ++ extraSbtFiles.toVector // Grab all the settings we already loaded from sbt files - def settings(files: Vector[VirtualFile]): Vector[Setting[_]] = + def settings(files: Vector[VirtualFile]): Vector[Setting[?]] = for file <- files config <- memoSettings.get(file).toSeq setting <- config.settings yield setting import AddSettings.* - def expandCommonSettings(auto: AddSettings): Vector[Setting[_]] = + def expandCommonSettings(auto: AddSettings): Vector[Setting[?]] = auto match case sf: DefaultSbtFiles => settings(sbtFiles.filter(sf.include)) case q: Sequence => - q.sequence.foldLeft(Vector.empty[Setting[_]]) { (b, add) => + q.sequence.foldLeft(Vector.empty[Setting[?]]) { (b, add) => b ++ expandCommonSettings(add) } case _ => Vector.empty @@ -1264,7 +1266,7 @@ private[sbt] object Load { )(loader) // How to merge SbtFiles we read into one thing def merge(ls: Seq[LoadedSbtFile]): LoadedSbtFile = ls.foldLeft(LoadedSbtFile.empty) { - _ merge _ + _.merge(_) } // Loads a given file, or pulls from the cache. @@ -1321,7 +1323,7 @@ private[sbt] object Load { case None => Nil /** These are the settings defined when loading a project "meta" build. */ - val autoPluginSettings: Seq[Setting[_]] = inScope(GlobalScope.rescope(LocalRootProject))( + val autoPluginSettings: Seq[Setting[?]] = inScope(GlobalScope.rescope(LocalRootProject))( Seq( sbtPlugin :== true, isMetaBuild :== true, @@ -1492,7 +1494,7 @@ private[sbt] object Load { new LoadedPlugins(dir, data, loader, PluginDiscovery.discoverAll(data, loader)) def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = { - val session = s get Keys.sessionSettings + val session = s.get(Keys.sessionSettings) val currentProject = session map (_.currentProject) getOrElse Map.empty val currentBuild = session .map(_.currentBuild) @@ -1522,9 +1524,12 @@ private[sbt] object Load { val units = structure.units val getRoot = getRootProject(units) def project(uri: URI) = { - current get uri filter { p => - structure allProjects uri map (_.id) contains p - } getOrElse getRoot(uri) + current + .get(uri) + .filter { p => + structure.allProjects(uri).map(_.id).contains(p) + } + .getOrElse(getRoot(uri)) } units.keys.map(uri => (uri, project(uri))).toMap } @@ -1534,17 +1539,17 @@ private[sbt] object Load { def referenced[PR <: ProjectReference](definitions: Seq[ProjectDefinition[PR]]): Seq[PR] = definitions flatMap { _.referenced } - final class EvaluatedConfigurations(val eval: Eval, val settings: Seq[Setting[_]]) + final class EvaluatedConfigurations(val eval: Eval, val settings: Seq[Setting[?]]) case class InjectSettings( - global: Seq[Setting[_]], - project: Seq[Setting[_]], - projectLoaded: ClassLoader => Seq[Setting[_]] + global: Seq[Setting[?]], + project: Seq[Setting[?]], + projectLoaded: ClassLoader => Seq[Setting[?]] ) { import java.net.URLClassLoader - private val cache: mutable.Map[String, Seq[Setting[_]]] = mutable.Map.empty + private val cache: mutable.Map[String, Seq[Setting[?]]] = mutable.Map.empty // Cache based on the underlying URL values of the classloader - def cachedProjectLoaded(cl: ClassLoader): Seq[Setting[_]] = + def cachedProjectLoaded(cl: ClassLoader): Seq[Setting[?]] = cl match { case cl: URLClassLoader => cache.getOrElseUpdate(classLoaderToHash(Some(cl)), projectLoaded(cl)) diff --git a/main/src/main/scala/sbt/internal/LogManager.scala b/main/src/main/scala/sbt/internal/LogManager.scala index f804f6509..d5268f61b 100644 --- a/main/src/main/scala/sbt/internal/LogManager.scala +++ b/main/src/main/scala/sbt/internal/LogManager.scala @@ -24,7 +24,7 @@ sealed abstract class LogManager { def apply( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], writer: PrintWriter, context: LoggerContext, ): ManagedLogger @@ -32,18 +32,18 @@ sealed abstract class LogManager { def apply( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], writer: PrintWriter ): ManagedLogger = apply(data, state, task, writer, LoggerContext.globalContext) def backgroundLog( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], context: LoggerContext ): ManagedLogger @deprecated("Use alternate background log that provides a LoggerContext", "1.4.0") - final def backgroundLog(data: Settings[Scope], state: State, task: ScopedKey[_]): ManagedLogger = + final def backgroundLog(data: Settings[Scope], state: State, task: ScopedKey[?]): ManagedLogger = backgroundLog(data, state, task, LoggerContext.globalContext) } @@ -52,7 +52,7 @@ sealed abstract class LogManager { * for LogManager.defaults with the old log4j variant. */ trait AppenderSupplier { - def apply(s: ScopedKey[_]): Seq[Appender] + def apply(s: ScopedKey[?]): Seq[Appender] } object LogManager { @@ -64,8 +64,8 @@ object LogManager { def construct( data: Settings[Scope], state: State - ): (ScopedKey[_], PrintWriter) => ManagedLogger = - (task: ScopedKey[_], to: PrintWriter) => { + ): (ScopedKey[?], PrintWriter) => ManagedLogger = + (task: ScopedKey[?], to: PrintWriter) => { val context = state.get(Keys.loggerContext).getOrElse(LoggerContext.globalContext) val manager: LogManager = (task.scope / logManager).get(data) getOrElse defaultManager(state.globalLogging.console) @@ -76,7 +76,7 @@ object LogManager { def constructBackgroundLog( data: Settings[Scope], state: State - ): ScopedKey[_] => ManagedLogger = { + ): ScopedKey[?] => ManagedLogger = { val context = state.get(Keys.loggerContext).getOrElse(LoggerContext.globalContext) constructBackgroundLog(data, state, context) } @@ -85,8 +85,8 @@ object LogManager { data: Settings[Scope], state: State, context: LoggerContext - ): (ScopedKey[_]) => ManagedLogger = - (task: ScopedKey[_]) => { + ): (ScopedKey[?]) => ManagedLogger = + (task: ScopedKey[?]) => { val manager: LogManager = (task.scope / logManager).get(data) getOrElse defaultManager(state.globalLogging.console) manager.backgroundLog(data, state, task, context) @@ -102,18 +102,18 @@ object LogManager { extra = extra ) - def withScreenLogger(mk: (ScopedKey[_], State) => Appender): LogManager = + def withScreenLogger(mk: (ScopedKey[?], State) => Appender): LogManager = withLoggers(screen = mk) def withLoggers( - screen: (ScopedKey[_], State) => Appender = (_, s) => defaultScreen(s.globalLogging.console), + screen: (ScopedKey[?], State) => Appender = (_, s) => defaultScreen(s.globalLogging.console), backed: PrintWriter => Appender = defaultBacked, relay: Unit => Appender = defaultRelay, extra: AppenderSupplier = _ => Nil ): LogManager = new DefaultLogManager(screen, backed, relay, extra) private class DefaultLogManager( - screen: (ScopedKey[_], State) => Appender, + screen: (ScopedKey[?], State) => Appender, backed: PrintWriter => Appender, relay: Unit => Appender, extra: AppenderSupplier @@ -121,7 +121,7 @@ object LogManager { def apply( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], to: PrintWriter, context: LoggerContext, ): ManagedLogger = @@ -139,7 +139,7 @@ object LogManager { def backgroundLog( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], context: LoggerContext ): ManagedLogger = { val console = ConsoleAppender.safe("bg-" + ConsoleAppender.generateName(), ITerminal.current) @@ -161,7 +161,7 @@ object LogManager { def defaultLogger( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], console: Appender, backed: Appender, relay: Appender, @@ -172,7 +172,7 @@ object LogManager { def defaultLogger( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], console: Appender, backed: Appender, relay: Appender, @@ -220,7 +220,7 @@ object LogManager { if (state.interactive) -1 else Int.MaxValue def suppressedMessage( - key: ScopedKey[_], + key: ScopedKey[?], state: State ): SuppressedTraceContext => Option[String] = { val display = Project.showContextKey(state) @@ -236,7 +236,7 @@ object LogManager { } } - def unwrapStreamsKey(key: ScopedKey[_]): ScopedKey[_] = key.scope.task match { + def unwrapStreamsKey(key: ScopedKey[?]): ScopedKey[?] = key.scope.task match { case Select(task) => ScopedKey(key.scope.copy(task = Zero), task) case _ => key // should never get here } @@ -244,7 +244,7 @@ object LogManager { def backgroundLog( data: Settings[Scope], state: State, - task: ScopedKey[_], + task: ScopedKey[?], console: Appender, /* TODO: backed: Appender,*/ relay: Appender, @@ -302,7 +302,7 @@ object LogManager { private lazy val defaultRelayImpl: ConsoleAppender = new RelayAppender("Relay0") - private[sbt] def settingsLogger(state: State): Def.Setting[_] = + private[sbt] def settingsLogger(state: State): Def.Setting[?] = // strict to avoid retaining a reference to `state` Global / sLog :== globalWrapper(state) diff --git a/main/src/main/scala/sbt/internal/Output.scala b/main/src/main/scala/sbt/internal/Output.scala index a1d599a3c..0ac67eff0 100644 --- a/main/src/main/scala/sbt/internal/Output.scala +++ b/main/src/main/scala/sbt/internal/Output.scala @@ -30,7 +30,7 @@ object Output { streams: Streams, printLines: Seq[String] => Unit, sid: Option[String] - )(using display: Show[ScopedKey[_]]): Unit = + )(using display: Show[ScopedKey[?]]): Unit = printLines(flatLines(lastLines(keys, streams, sid))(idFun)) def last(file: File, printLines: Seq[String] => Unit, tailDelim: String = DefaultTail): Unit = @@ -41,7 +41,7 @@ object Output { streams: Streams, patternString: String, printLines: Seq[String] => Unit - )(using display: Show[ScopedKey[_]]): Unit = { + )(using display: Show[ScopedKey[?]]): Unit = { val pattern = Pattern.compile(patternString) val lines = flatLines(lastLines(keys, streams))(_ flatMap showMatches(pattern)) printLines(lines) @@ -56,10 +56,10 @@ object Output { printLines(grep(tailLines(file, tailDelim), patternString)) def grep(lines: Seq[String], patternString: String): Seq[String] = - lines flatMap showMatches(Pattern compile patternString) + lines.flatMap(showMatches(Pattern.compile(patternString))) def flatLines(outputs: Values[Seq[String]])(f: Seq[String] => Seq[String])(implicit - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): Seq[String] = { val single = outputs.size == 1 outputs flatMap { case KeyValue(key, lines) => @@ -73,20 +73,20 @@ object Output { streams: Streams, sid: Option[String] = None ): Values[Seq[String]] = { - val outputs = keys map { (kv: KeyValue[_]) => + val outputs = keys map { (kv: KeyValue[?]) => KeyValue(kv.key, lastLines(kv.key, streams, sid)) } outputs.filterNot(_.value.isEmpty) } - def lastLines(key: ScopedKey[_], mgr: Streams, sid: Option[String]): Seq[String] = + def lastLines(key: ScopedKey[?], mgr: Streams, sid: Option[String]): Seq[String] = mgr.use(key) { s => // Workaround for #1155 - Keys.streams are always scoped by the task they're included in // but are keyed by the Keys.streams key. I think this isn't actually a workaround, but // is how things are expected to work now. // You can see where streams are injected using their own key scope in // EvaluateTask.injectStreams. - val streamScopedKey: ScopedKey[_] = + val streamScopedKey: ScopedKey[?] = ScopedKey(Project.fillTaskAxis(key).scope, Keys.streams.key) val tmp = s.readText(streamScopedKey, sid) IO.readLines(tmp) @@ -99,7 +99,7 @@ object Output { if (lines.isEmpty) lines else { val (first, tail) = lines.span { line => - !(line startsWith tailDelim) + !line.startsWith(tailDelim) } if (first.isEmpty) headLines(tail drop 1, tailDelim) else first } diff --git a/main/src/main/scala/sbt/internal/PluginDiscovery.scala b/main/src/main/scala/sbt/internal/PluginDiscovery.scala index 0e31ff607..40e3863b7 100644 --- a/main/src/main/scala/sbt/internal/PluginDiscovery.scala +++ b/main/src/main/scala/sbt/internal/PluginDiscovery.scala @@ -106,7 +106,7 @@ object PluginDiscovery: ): Seq[String] = ( binaryModuleNames(classpath, converter, loader, resourceName) ++ - analyzed(classpath, converter).flatMap(a => sourceModuleNames(a, subclasses: _*)) + analyzed(classpath, converter).flatMap(a => sourceModuleNames(a, subclasses*)) ).distinct /** Discovers top-level modules in `analysis` that inherit from any of `subclasses`. */ @@ -145,7 +145,7 @@ object PluginDiscovery: /** Returns `true` if `url` is an entry in `classpath`. */ def onClasspath(classpath: Def.Classpath, converter: FileConverter)(url: URL): Boolean = val cpFiles = classpath.map(_.data).map(converter.toPath).map(_.toFile) - IO.urlAsFile(url) exists (cpFiles.contains _) + IO.urlAsFile(url) exists (cpFiles.contains) private[sbt] def binarySourceModules[A: ClassTag]( data: PluginData, diff --git a/main/src/main/scala/sbt/internal/PluginManagement.scala b/main/src/main/scala/sbt/internal/PluginManagement.scala index cf1a6af62..63e0aa8f9 100644 --- a/main/src/main/scala/sbt/internal/PluginManagement.scala +++ b/main/src/main/scala/sbt/internal/PluginManagement.scala @@ -38,7 +38,7 @@ final case class PluginManagement( def addOverrides(cp: Classpath): PluginManagement = addOverrides(extractOverrides(cp)) - def inject: Seq[Setting[_]] = Seq( + def inject: Seq[Setting[?]] = Seq( Keys.dependencyOverrides ++= overrides.toVector ) diff --git a/main/src/main/scala/sbt/internal/PluginsDebug.scala b/main/src/main/scala/sbt/internal/PluginsDebug.scala index cdd410a87..0f0fc0bc1 100644 --- a/main/src/main/scala/sbt/internal/PluginsDebug.scala +++ b/main/src/main/scala/sbt/internal/PluginsDebug.scala @@ -20,8 +20,8 @@ import java.net.URI private[sbt] class PluginsDebug( val available: List[AutoPlugin], - val nameToKey: Map[String, AttributeKey[_]], - val provided: Relation[AutoPlugin, AttributeKey[_]] + val nameToKey: Map[String, AttributeKey[?]], + val provided: Relation[AutoPlugin, AttributeKey[?]] ) { /** @@ -216,7 +216,7 @@ private[sbt] object PluginsDebug { /** Pre-computes information for debugging plugins. */ def apply(available: List[AutoPlugin]): PluginsDebug = { val keyR = definedKeys(available) - val nameToKey: Map[String, AttributeKey[_]] = + val nameToKey: Map[String, AttributeKey[?]] = keyR._2s.toList.map(key => (key.label, key)).toMap new PluginsDebug(available, nameToKey, keyR) } @@ -431,12 +431,12 @@ private[sbt] object PluginsDebug { * Provides a [[Relation]] between plugins and the keys they potentially define. * Because plugins can define keys in different scopes and keys can be overridden, this is not definitive. */ - def definedKeys(available: List[AutoPlugin]): Relation[AutoPlugin, AttributeKey[_]] = { - def extractDefinedKeys(ss: Seq[Setting[_]]): Seq[AttributeKey[_]] = + def definedKeys(available: List[AutoPlugin]): Relation[AutoPlugin, AttributeKey[?]] = { + def extractDefinedKeys(ss: Seq[Setting[?]]): Seq[AttributeKey[?]] = ss.map(_.key.key) - def allSettings(p: AutoPlugin): Seq[Setting[_]] = + def allSettings(p: AutoPlugin): Seq[Setting[?]] = p.projectSettings ++ p.buildSettings ++ p.globalSettings - val empty = Relation.empty[AutoPlugin, AttributeKey[_]] + val empty = Relation.empty[AutoPlugin, AttributeKey[?]] available.foldLeft(empty)((r, p) => r + (p, extractDefinedKeys(allSettings(p)))) } diff --git a/main/src/main/scala/sbt/internal/ProjectQuery.scala b/main/src/main/scala/sbt/internal/ProjectQuery.scala index 00cd29485..33743eabf 100644 --- a/main/src/main/scala/sbt/internal/ProjectQuery.scala +++ b/main/src/main/scala/sbt/internal/ProjectQuery.scala @@ -46,7 +46,7 @@ object ProjectQuery: .examples("@scalaBinaryVersion=3") .?) .map { case (proj, params) => - ProjectQuery(proj, Map(params.toSeq: _*)) + ProjectQuery(proj, Map(params.toSeq*)) } .filter( (q) => q.projectName.contains("...") || q.params.nonEmpty, diff --git a/main/src/main/scala/sbt/internal/Resolve.scala b/main/src/main/scala/sbt/internal/Resolve.scala index e4842f697..710b57bc0 100644 --- a/main/src/main/scala/sbt/internal/Resolve.scala +++ b/main/src/main/scala/sbt/internal/Resolve.scala @@ -13,16 +13,16 @@ import sbt.internal.util.AttributeKey object Resolve { def apply( - index: BuildUtil[_], + index: BuildUtil[?], current: ScopeAxis[Reference], - key: AttributeKey[_], + key: AttributeKey[?], mask: ScopeMask, ): Scope => Scope = { val rs = ( - resolveProject(current, mask) _ - :: resolveExtra(mask) _ - :: resolveTask(mask) _ - :: resolveConfig(index, key, mask) _ + resolveProject(current, mask) + :: resolveExtra(mask) + :: resolveTask(mask) + :: resolveConfig(index, key, mask) :: Nil ) scope => rs.foldLeft(scope)((s, f) => f(s)) @@ -40,7 +40,7 @@ object Resolve { if (mask.extra) scope else scope.copy(extra = Zero) - def resolveConfig[P](index: BuildUtil[P], key: AttributeKey[_], mask: ScopeMask)( + def resolveConfig[P](index: BuildUtil[P], key: AttributeKey[?], mask: ScopeMask)( scope: Scope, ): Scope = if (mask.config) scope @@ -48,7 +48,7 @@ object Resolve { val (resolvedRef, proj) = scope.project match { case Zero | This => (None, index.thisRootProject) case Select(ref) => - val r = index resolveRef ref + val r = index.resolveRef(ref) (Some(r), index.projectFor(r)) } val task = scope.task.toOption diff --git a/main/src/main/scala/sbt/internal/SessionSettings.scala b/main/src/main/scala/sbt/internal/SessionSettings.scala index 9b419c935..33f2e55e1 100755 --- a/main/src/main/scala/sbt/internal/SessionSettings.scala +++ b/main/src/main/scala/sbt/internal/SessionSettings.scala @@ -32,9 +32,9 @@ import sbt.io.IO final case class SessionSettings( currentBuild: URI, currentProject: Map[URI, String], - original: Seq[Setting[_]], + original: Seq[Setting[?]], append: SessionMap, - rawAppend: Seq[Setting[_]], + rawAppend: Seq[Setting[?]], currentEval: () => Eval ) { @@ -76,19 +76,19 @@ final case class SessionSettings( * @param ss The raw settings to include * @return A new SessionSettings with the appended settings. */ - def appendRaw(ss: Seq[Setting[_]]): SessionSettings = copy(rawAppend = rawAppend ++ ss) + def appendRaw(ss: Seq[Setting[?]]): SessionSettings = copy(rawAppend = rawAppend ++ ss) /** * @return A combined list of all Setting[_] objects for the current session, in priority order. */ - def mergeSettings: Seq[Setting[_]] = original ++ merge(append) ++ rawAppend + def mergeSettings: Seq[Setting[?]] = original ++ merge(append) ++ rawAppend /** * @return A new SessionSettings object where additional transient settings are removed. */ def clearExtraSettings: SessionSettings = copy(append = Map.empty, rawAppend = Nil) - private def merge(map: SessionMap): Seq[Setting[_]] = + private def merge(map: SessionMap): Seq[Setting[?]] = map.values.toSeq.flatten[SessionSetting].map(_._1) private def modify( @@ -146,7 +146,7 @@ object SessionSettings: /** Checks to see if any session settings are being discarded and issues a warning. */ def checkSession(newSession: SessionSettings, oldState: State): Unit = { - val oldSettings = (oldState get Keys.sessionSettings).toList.flatMap(_.append).flatMap(_._2) + val oldSettings = oldState.get(Keys.sessionSettings).toList.flatMap(_.append).flatMap(_._2) if (newSession.append.isEmpty && oldSettings.nonEmpty) oldState.log.warn( "Discarding " + pluralize( @@ -206,9 +206,9 @@ object SessionSettings: def writeSettings( pref: ProjectRef, settings: List[SessionSetting], - original: Seq[Setting[_]], + original: Seq[Setting[?]], structure: BuildStructure - ): (Seq[SessionSetting], Seq[Setting[_]]) = { + ): (Seq[SessionSetting], Seq[Setting[?]]) = { val project = Project.getProject(pref, structure).getOrElse(sys.error("Invalid project reference " + pref)) val writeTo: File = BuildPaths @@ -219,7 +219,7 @@ object SessionSettings: val path = writeTo.getAbsolutePath val (inFile, other, _) = - original.reverse.foldLeft((List[Setting[_]](), List[Setting[_]](), Set.empty[ScopedKey[_]])) { + original.reverse.foldLeft((List[Setting[?]](), List[Setting[?]](), Set.empty[ScopedKey[?]])) { case ((in, oth, keys), s) => s.pos match { case RangePosition(`path`, _) if !keys.contains(s.key) => (s :: in, oth, keys + s.key) @@ -227,18 +227,20 @@ object SessionSettings: } } - val (_, oldShifted, replace) = inFile.foldLeft((0, List[Setting[_]](), Seq[SessionSetting]())) { + val (_, oldShifted, replace) = inFile.foldLeft((0, List[Setting[?]](), Seq[SessionSetting]())) { case ((offs, olds, repl), s) => val RangePosition(_, r @ LineRange(start, end)) = s.pos: @unchecked - settings find (_._1.key == s.key) match { + settings.find(_._1.key == s.key) match { case Some(ss @ (ns, newLines)) if !ns.init.dependencies.contains(ns.key) => - val shifted = ns withPos RangePosition( - path, - LineRange(start - offs, start - offs + newLines.size) + val shifted = ns.withPos( + RangePosition( + path, + LineRange(start - offs, start - offs + newLines.size) + ) ) (offs + end - start - newLines.size, shifted :: olds, ss +: repl) case _ => - val shifted = s withPos RangePosition(path, r shift -offs) + val shifted = s.withPos(RangePosition(path, r.shift(-offs))) (offs, shifted :: olds, repl) } } @@ -251,7 +253,7 @@ object SessionSettings: val (newWithPos, _) = newSettings.foldLeft((List[SessionSetting](), adjusted.size + 1)) { case ((acc, line), (s, newLines)) => val endLine = line + newLines.size - ((s withPos RangePosition(path, LineRange(line, endLine)), newLines) :: acc, endLine + 1) + ((s.withPos(RangePosition(path, LineRange(line, endLine))), newLines) :: acc, endLine + 1) } (newWithPos.reverse, other ++ oldShifted) } diff --git a/main/src/main/scala/sbt/internal/SettingCompletions.scala b/main/src/main/scala/sbt/internal/SettingCompletions.scala index 7b16a260b..615ed67e8 100644 --- a/main/src/main/scala/sbt/internal/SettingCompletions.scala +++ b/main/src/main/scala/sbt/internal/SettingCompletions.scala @@ -39,7 +39,7 @@ private[sbt] object SettingCompletions { * overriding all previous definitions of the underlying AttributeKey. * The settings injected by this method cannot be later persisted by the `session save` command. */ - def setAll(extracted: Extracted, settings: Seq[Setting[_]]): SetResult = { + def setAll(extracted: Extracted, settings: Seq[Setting[?]]): SetResult = { import extracted._ val r = Project.relation(extracted.structure, true) val allDefs = Def @@ -47,15 +47,15 @@ private[sbt] object SettingCompletions { Def.compiled(extracted.structure.settings, true)(using structure.delegates, structure.scopeLocal, - implicitly[Show[ScopedKey[_]]], + implicitly[Show[ScopedKey[?]]], ) ) .keys val projectScope = Load.projectScope(currentRef) - def resolve(s: Setting[_]): Seq[Setting[_]] = + def resolve(s: Setting[?]): Seq[Setting[?]] = Load.transformSettings(projectScope, currentRef.build, rootProject, s :: Nil) - def rescope[T](setting: Setting[T]): Seq[Setting[_]] = { + def rescope[T](setting: Setting[T]): Seq[Setting[?]] = { val akey = setting.key.key val global = ScopedKey(Global, akey) val globalSetting = resolve(Def.setting(global, setting.init, setting.pos)) @@ -73,7 +73,7 @@ private[sbt] object SettingCompletions { * Implementation of the `set` command that will reload the current project with `settings` * appended to the current settings. */ - def setThis(extracted: Extracted, settings: Seq[Def.Setting[_]], arg: String): SetResult = { + def setThis(extracted: Extracted, settings: Seq[Def.Setting[?]], arg: String): SetResult = { import extracted._ val append = Load.transformSettings(Load.projectScope(currentRef), currentRef.build, rootProject, settings) @@ -81,16 +81,16 @@ private[sbt] object SettingCompletions { val r = Project.relation(newSession.mergeSettings, true)(using structure.delegates, structure.scopeLocal, - summon[Show[ScopedKey[_]]], + summon[Show[ScopedKey[?]]], ) setResult(newSession, r, append) } private def setResult( session: SessionSettings, - r: Relation[ScopedKey[_], ScopedKey[_]], - redefined: Seq[Setting[_]], - )(implicit show: Show[ScopedKey[_]]): SetResult = { + r: Relation[ScopedKey[?], ScopedKey[?]], + redefined: Seq[Setting[?]], + )(implicit show: Show[ScopedKey[?]]): SetResult = { val redefinedKeys = redefined.map(_.key).toSet val affectedKeys = redefinedKeys.flatMap(r.reverse) def summary(verbose: Boolean): String = setSummary(redefinedKeys, affectedKeys, verbose) @@ -98,12 +98,12 @@ private[sbt] object SettingCompletions { } private def setSummary( - redefined: Set[ScopedKey[_]], - affected: Set[ScopedKey[_]], + redefined: Set[ScopedKey[?]], + affected: Set[ScopedKey[?]], verbose: Boolean, - )(implicit display: Show[ScopedKey[_]]): String = { + )(implicit display: Show[ScopedKey[?]]): String = { val QuietLimit = 3 - def strings(in: Set[ScopedKey[_]]): Seq[String] = in.toSeq.map(sk => display.show(sk)).sorted + def strings(in: Set[ScopedKey[?]]): Seq[String] = in.toSeq.map(sk => display.show(sk)).sorted def lines(in: Seq[String]): (String, Boolean) = if (in.isEmpty) ("no settings or tasks.", false) @@ -139,10 +139,10 @@ private[sbt] object SettingCompletions { */ def settingParser( settings: Settings[Scope], - rawKeyMap: Map[String, AttributeKey[_]], + rawKeyMap: Map[String, AttributeKey[?]], context: ResolvedProject, ): Parser[String] = { - val keyMap: Map[String, AttributeKey[_]] = + val keyMap: Map[String, AttributeKey[?]] = rawKeyMap.map { case (k, v) => (keyScalaID(k), v) }.toMap val full = for { defineKey <- scopedKeyParser(keyMap, settings, context) @@ -155,15 +155,15 @@ private[sbt] object SettingCompletions { /** Parser for a Scope+AttributeKey (ScopedKey). */ def scopedKeyParser( - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], settings: Settings[Scope], context: ResolvedProject - ): Parser[ScopedKey[_]] = { + ): Parser[ScopedKey[?]] = { val cutoff = KeyRanks.MainCutoff val keyCompletions = fixedCompletions { (seen, level) => completeKey(seen, keyMap, level, cutoff, 10).toSet } - val keyID: Parser[AttributeKey[_]] = scalaID(keyMap, "key") + val keyID: Parser[AttributeKey[?]] = scalaID(keyMap, "key") val keyParser = token(keyID, keyCompletions) for (key <- keyParser; scope <- scopeParser(key, settings, context)) yield ScopedKey(scope, key) @@ -176,7 +176,7 @@ private[sbt] object SettingCompletions { * Parser for the initialization expression for the assignment method `assign` on the key `sk`. * `scopedKeyP` is used to parse and complete the input keys for an initialization that depends on other keys. */ - def valueParser(sk: ScopedKey[_], assign: Assign.Value): Parser[Seq[ScopedKey[_]]] = { + def valueParser(sk: ScopedKey[?], assign: Assign.Value): Parser[Seq[ScopedKey[?]]] = { val fullTypeString = keyTypeString(sk.key) val typeString = if (assignNoAppend(assign)) fullTypeString else "..." if (assign == Assign.Update) { @@ -194,14 +194,14 @@ private[sbt] object SettingCompletions { * only known axis values for configurations and tasks and only in that order. */ def scopeParser( - key: AttributeKey[_], + key: AttributeKey[?], settings: Settings[Scope], context: ResolvedProject ): Parser[Scope] = { val data = settings.data val allScopes = data.keys.toSeq val definedScopes = data.toSeq flatMap { case (scope, attrs) => - if (attrs contains key) scope :: Nil else Nil + if attrs.contains(key) then scope :: Nil else Nil } scope(allScopes, definedScopes, context) } @@ -242,19 +242,25 @@ private[sbt] object SettingCompletions { "configuration", ) val taskParser = - axisParser[AttributeKey[_]](_.task, k => keyScalaID(k.label), _.description, "task") + axisParser[AttributeKey[?]](_.task, k => keyScalaID(k.label), _.description, "task") val nonGlobal = (configParser ~ taskParser) map { case (c, t) => Scope(This, c, t, Zero) } val global = inParser ~> token((Space ~ GlobalID) ^^^ Global) global | nonGlobal } /** Parser for the assignment method (such as `:=`) for defining `key`. */ - def assign(key: ScopedKey[_]): Parser[Assign.Value] = { + def assign(key: ScopedKey[?]): Parser[Assign.Value] = { val completions = fixedCompletions { (seen, _) => completeAssign(seen, key).toSet } val identifier = - Act.filterStrings(Op, Assign.values.map(_.toString), "assignment method") map Assign.withName + Act + .filterStrings( + Op, + Assign.values.map(_.toString), + "assignment method" + ) + .map(Assign.withName) token(Space) ~> token(optionallyQuoted(identifier), completions) } @@ -262,7 +268,9 @@ private[sbt] object SettingCompletions { TokenCompletions.fixed((s, l) => Completions(f(s, l))) private def scalaID[T](keyMap: Map[String, T], label: String): Parser[T] = { - val identifier = Act.filterStrings(ScalaID, keyMap.keySet, label) map keyMap + val identifier = Act + .filterStrings(ScalaID, keyMap.keySet, label) + .map(keyMap) optionallyQuoted(identifier) } @@ -276,20 +284,20 @@ private[sbt] object SettingCompletions { * Completions for an assignment method for `key` given the tab completion `level` and existing partial string `seen`. * This will filter possible assignment methods based on the underlying type of `key`, so that only `<<=` is shown for input tasks, for example. */ - def completeAssign(seen: String, key: ScopedKey[_]): Seq[Completion] = { + def completeAssign(seen: String, key: ScopedKey[?]): Seq[Completion] = { val allowed: Iterable[Assign.Value] = if (appendable(key.key)) Assign.values else assignNoAppend val applicable = allowed.toSeq.flatMap { a => val s = a.toString - if (s startsWith seen) (s, a) :: Nil else Nil + if s.startsWith(seen) then (s, a) :: Nil else Nil } completeDescribed(seen, true, applicable)(assignDescription) } def completeKey( seen: String, - keys: Map[String, AttributeKey[_]], + keys: Map[String, AttributeKey[?]], level: Int, prominentCutoff: Int, detailLimit: Int @@ -311,7 +319,7 @@ private[sbt] object SettingCompletions { def completeSelectDescribed[T](seen: String, level: Int, all: Map[String, T], detailLimit: Int)( description: T => Option[String] )(prominent: (String, T) => Boolean): Seq[Completion] = { - val applicable = all.toSeq.filter { case (k, _) => k startsWith seen } + val applicable = all.toSeq.filter { case (k, _) => k.startsWith(seen) } val prominentOnly = applicable filter { case (k, v) => prominent(k, v) } val showAll = (level >= 3) || (level == 2 && prominentOnly.lengthCompare( @@ -352,11 +360,11 @@ private[sbt] object SettingCompletions { * Returns a string representation of the underlying type T for a `key` representing a `Setting[T]`, `Task[T]`, or `InputTask[T]`. * This string representation is currently a cleaned up toString of the underlying ClassTag. */ - def keyTypeString[T](key: AttributeKey[_]): String = + def keyTypeString[T](key: AttributeKey[?]): String = complete.TypeString.cleanup(key.tag.typeArg.toString) /** True if the `key` represents a setting or task that may be appended using an assignment method such as `+=`. */ - def appendable(key: AttributeKey[_]): Boolean = + def appendable(key: AttributeKey[?]): Boolean = appendableClasses.exists(_.isAssignableFrom(key.tag.typeArg)) /** The simple name of the Global scope, which can be used to reference it in the default setting context. */ @@ -390,9 +398,9 @@ private[sbt] object SettingCompletions { /** Class values to approximate which types can be appended */ val appendableClasses = Seq( - classOf[Seq[_]], - classOf[Map[_, _]], - classOf[Set[_]], + classOf[Seq[?]], + classOf[Map[?, ?]], + classOf[Set[?]], classOf[Int], classOf[Double], classOf[Long], diff --git a/main/src/main/scala/sbt/internal/SettingGraph.scala b/main/src/main/scala/sbt/internal/SettingGraph.scala index e7b65c438..5d66531f8 100644 --- a/main/src/main/scala/sbt/internal/SettingGraph.scala +++ b/main/src/main/scala/sbt/internal/SettingGraph.scala @@ -18,13 +18,13 @@ import sbt.ProjectExtra.scopedKeyData import sbt.io.IO object SettingGraph { - def apply(structure: BuildStructure, basedir: File, scoped: ScopedKey[_], generation: Int)(using - display: Show[ScopedKey[_]] + def apply(structure: BuildStructure, basedir: File, scoped: ScopedKey[?], generation: Int)(using + display: Show[ScopedKey[?]] ): SettingGraph = { val cMap = flattenLocals( compiled(structure.settings, false)(using structure.delegates, structure.scopeLocal, display) ) - def loop(scoped: ScopedKey[_], generation: Int): SettingGraph = { + def loop(scoped: ScopedKey[?], generation: Int): SettingGraph = { val key = scoped.key val scope = scoped.scope val definedIn = structure.data.definingScope(scope, key) map { sc => @@ -42,7 +42,7 @@ object SettingGraph { Project.scopedKeyData(structure, scope, key), key.description, basedir, - depends map { (x: ScopedKey[_]) => + depends map { (x: ScopedKey[?]) => loop(x, generation + 1) } ) @@ -54,7 +54,7 @@ object SettingGraph { case class SettingGraph( name: String, definedIn: Option[String], - data: Option[ScopedKeyData[_]], + data: Option[ScopedKeyData[?]], description: Option[String], basedir: File, depends: Set[SettingGraph] @@ -105,7 +105,7 @@ object Graph { Vector(limitLine((twoSpaces * level) + "#-" + display(node) + " (cycle)")) else { val line = limitLine((twoSpaces * level) + (if (level == 0) "" else "+-") + display(node)) - val cs = Vector(children(node): _*) + val cs = Vector(children(node)*) val childLines = cs map { toAsciiLines(_, level + 1, parents + node) } diff --git a/main/src/main/scala/sbt/internal/TaskName.scala b/main/src/main/scala/sbt/internal/TaskName.scala index f84dd3126..45199bc66 100644 --- a/main/src/main/scala/sbt/internal/TaskName.scala +++ b/main/src/main/scala/sbt/internal/TaskName.scala @@ -13,11 +13,11 @@ import Def.{ displayFull, ScopedKey } import Keys.taskDefinitionKey private[sbt] object TaskName { - def name(node: Task[_]): String = definedName(node).getOrElse(anonymousName(node)) - def definedName(node: Task[_]): Option[String] = + def name(node: Task[?]): String = definedName(node).getOrElse(anonymousName(node)) + def definedName(node: Task[?]): Option[String] = node.info.name.orElse(transformNode(node).map(displayFull)) - def anonymousName(node: TaskId[_]): String = + def anonymousName(node: TaskId[?]): String = "" - def transformNode(node: Task[_]): Option[ScopedKey[_]] = + def transformNode(node: Task[?]): Option[ScopedKey[?]] = node.info.attributes.get(taskDefinitionKey) } diff --git a/main/src/main/scala/sbt/internal/TaskProgress.scala b/main/src/main/scala/sbt/internal/TaskProgress.scala index 87dc035b9..3a7c10cf5 100644 --- a/main/src/main/scala/sbt/internal/TaskProgress.scala +++ b/main/src/main/scala/sbt/internal/TaskProgress.scala @@ -31,11 +31,11 @@ private[sbt] class TaskProgress( with AutoCloseable { private val lastTaskCount = new AtomicInteger(0) private val reportLoop = new AtomicReference[AutoCloseable] - private val active = new ConcurrentHashMap[TaskId[_], AutoCloseable] + private val active = new ConcurrentHashMap[TaskId[?], AutoCloseable] private val nextReport = new AtomicReference(Deadline.now) private val scheduler = Executors.newSingleThreadScheduledExecutor(r => new Thread(r, "sbt-progress-report-scheduler")) - private val pending = new java.util.Vector[java.util.concurrent.Future[_]] + private val pending = new java.util.Vector[java.util.concurrent.Future[?]] private val closed = new AtomicBoolean(false) private def schedule[R](duration: FiniteDuration, recurring: Boolean)(f: => R): AutoCloseable = if (!closed.get) { @@ -167,7 +167,7 @@ private[sbt] class TaskProgress( val ltc = lastTaskCount.get if (currentTasks.nonEmpty || ltc != 0) { val currentTasksCount = currentTasks.size - def event(tasks: Vector[(TaskId[_], Long)]): ProgressEvent = { + def event(tasks: Vector[(TaskId[?], Long)]): ProgressEvent = { if (tasks.nonEmpty) nextReport.set(Deadline.now + sleepDuration) val toWrite = tasks.sortBy(_._2) val distinct = new java.util.LinkedHashMap[String, ProgressItem] @@ -190,7 +190,7 @@ private[sbt] class TaskProgress( } } - private def getShortName(task: TaskId[_]): String = { + private def getShortName(task: TaskId[?]): String = { val name = taskName(task) name.lastIndexOf('/') match { case -1 => name @@ -202,9 +202,9 @@ private[sbt] class TaskProgress( } private def filter( - tasks: Vector[(TaskId[_], Long)] - ): (Vector[(TaskId[_], Long)], Boolean) = { - tasks.foldLeft((Vector.empty[(TaskId[_], Long)], false)) { + tasks: Vector[(TaskId[?], Long)] + ): (Vector[(TaskId[?], Long)], Boolean) = { + tasks.foldLeft((Vector.empty[(TaskId[?], Long)], false)) { case ((tasks, skip), pair @ (t, _)) => val shortName = getShortName(t) val newSkip = skip || skipReportTasks.contains(shortName) diff --git a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala index e4ad1fa25..d0c29b518 100644 --- a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala +++ b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala @@ -34,7 +34,7 @@ private[sbt] object WatchTransitiveDependencies { private[sbt] def task: Def.Initialize[Task[Seq[DynamicInput]]] = Def.task(transitiveDynamicInputs(arguments.value)) private[sbt] def task( - key: ScopedKey[_] + key: ScopedKey[?] ): Def.Initialize[Task[Seq[DynamicInput]]] = withParams((e, cm) => Def.task(transitiveDynamicInputs(argumentsImpl(key, e, cm).value))) private def withParams[R]( @@ -46,7 +46,7 @@ private[sbt] object WatchTransitiveDependencies { private[sbt] def compile(structure: BuildStructure): CompiledMap = structure.compiledMap private[sbt] final class Arguments( - val scopedKey: ScopedKey[_], + val scopedKey: ScopedKey[?], val extracted: Extracted, val compiledMap: CompiledMap, val log: sbt.util.Logger, @@ -58,7 +58,7 @@ private[sbt] object WatchTransitiveDependencies { } private def argumentsImpl( - scopedKey: ScopedKey[_], + scopedKey: ScopedKey[?], extracted: Extracted, compiledMap: CompiledMap ): Def.Initialize[Task[Arguments]] = @@ -103,12 +103,12 @@ private[sbt] object WatchTransitiveDependencies { private[sbt] def transitiveDynamicInputs(args: Arguments): Seq[DynamicInput] = { import args._ val taskScope = Project.fillTaskAxis(scopedKey).scope - def delegates(sk: ScopedKey[_]): Seq[ScopedKey[_]] = + def delegates(sk: ScopedKey[?]): Seq[ScopedKey[?]] = Project.delegates(structure, sk.scope, sk.key) // We add the triggers to the delegate scopes to make it possible for the user to do something // like: Compile / compile / watchTriggers += baseDirectory.value ** "*.proto". We do not do the // same for inputs because inputs are expected to be explicitly used as part of the task. - val allKeys: Seq[ScopedKey[_]] = + val allKeys: Seq[ScopedKey[?]] = (delegates(scopedKey).toSet ++ delegates(ScopedKey(taskScope, watchTriggers.key))).toSeq val keys = collectKeys(args, allKeys, Set.empty, Set.empty) def getDynamicInputs(scopedKey: ScopedKey[Seq[Glob]], trigger: Boolean): Seq[DynamicInput] = { @@ -139,7 +139,7 @@ private[sbt] object WatchTransitiveDependencies { (inputGlobs ++ triggerGlobs ++ legacy(keys :+ scopedKey, args)).distinct.sorted } - private def legacy(keys: Seq[ScopedKey[_]], args: Arguments): Seq[DynamicInput] = { + private def legacy(keys: Seq[ScopedKey[?]], args: Arguments): Seq[DynamicInput] = { import args._ val projectScopes = keys.view @@ -176,9 +176,9 @@ private[sbt] object WatchTransitiveDependencies { @tailrec private def collectKeys( arguments: Arguments, - dependencies: Seq[ScopedKey[_]], + dependencies: Seq[ScopedKey[?]], accumulator: Set[ScopedKey[Seq[Glob]]], - visited: Set[ScopedKey[_]] + visited: Set[ScopedKey[?]] ): Seq[ScopedKey[Seq[Glob]]] = dependencies match { // Iterates until the dependency list is empty. The visited parameter prevents the graph // traversal from getting stuck in a cycle. @@ -190,7 +190,7 @@ private[sbt] object WatchTransitiveDependencies { case key: ScopedKey[Seq[Glob]] @unchecked if isGlobKey(key) => key :: Nil case _ => Nil } - val base: (Seq[ScopedKey[_]], Seq[ScopedKey[Seq[Glob]]]) = (Nil, baseGlobs) + val base: (Seq[ScopedKey[?]], Seq[ScopedKey[Seq[Glob]]]) = (Nil, baseGlobs) val (newDependencies, newScopes) = (compiled.dependencies.filterNot(newVisited) ++ compiled.settings.map(_.key)) .foldLeft(base) { @@ -234,7 +234,7 @@ private[sbt] object WatchTransitiveDependencies { } case _ => accumulator.toIndexedSeq } - private def isGlobKey(key: ScopedKey[_]): Boolean = key.key match { + private def isGlobKey(key: ScopedKey[?]): Boolean = key.key match { case fileInputs.key | watchTriggers.key => true case _ => false } diff --git a/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala b/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala index b6872e23f..5457b971b 100644 --- a/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala +++ b/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala @@ -230,7 +230,7 @@ object IvyXml { def generateIvyXmlSettings( shadedConfigOpt: Option[Configuration] = None - ): Seq[Setting[_]] = + ): Seq[Setting[?]] = (needsIvyXml ++ needsIvyXmlLocal).map(makeIvyXmlBefore(_, shadedConfigOpt)) } diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index ed9f338a4..2e40bf6b7 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -83,7 +83,7 @@ object BuildServerProtocol { } ) - lazy val globalSettings: Seq[Def.Setting[_]] = Seq( + lazy val globalSettings: Seq[Def.Setting[?]] = Seq( bspConfig := { if (bspEnabled.value) { BuildServerConnection.writeConnectionFile( @@ -267,7 +267,7 @@ object BuildServerProtocol { ) // This will be scoped to Compile, Test, IntegrationTest etc - lazy val configSettings: Seq[Def.Setting[_]] = Seq( + lazy val configSettings: Seq[Def.Setting[?]] = Seq( bspTargetIdentifier := { val ref = thisProjectRef.value val c = configuration.value @@ -1030,7 +1030,7 @@ object BuildServerProtocol { .groupBy(_._1) .mapValues { deps => // We use a list set to maintain the order of configs - ListSet(deps.flatMap { case (_, configs) => configs }: _*) + ListSet(deps.flatMap { case (_, configs) => configs }*) } .toSeq } diff --git a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala index d6abd1aec..73b559350 100644 --- a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala +++ b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala @@ -439,7 +439,7 @@ final class NetworkChannel( .map(c => cp.query + c) } val (items, cachedMainClassNames, cachedTestNames) = { - val scopedKeyParser: Parser[Seq[Def.ScopedKey[_]]] = + val scopedKeyParser: Parser[Seq[Def.ScopedKey[?]]] = Act.aggregatedKeyParser(sstate) <~ Parsers.any.* Parser.parse(cp.query, scopedKeyParser) match { case Right(keys) => @@ -687,7 +687,7 @@ final class NetworkChannel( if (!list.isEmpty) jsonRpcNotify(Serialization.systemOut, list.asScala.toSeq) } - private lazy val outputStream: OutputStream with AutoCloseable = new OutputStream + private lazy val outputStream: OutputStream & AutoCloseable = new OutputStream with AutoCloseable { /* * We buffer calls to flush to the remote client so that it is called at most @@ -700,7 +700,7 @@ final class NetworkChannel( * probably long enough to catch each burst but short enough to not introduce * noticeable latency. */ - private val flushFuture = new AtomicReference[java.util.concurrent.Future[_]] + private val flushFuture = new AtomicReference[java.util.concurrent.Future[?]] override def close(): Unit = { forceFlush() } diff --git a/main/src/main/scala/sbt/internal/server/SettingQuery.scala b/main/src/main/scala/sbt/internal/server/SettingQuery.scala index 5a1683330..86a824c3f 100644 --- a/main/src/main/scala/sbt/internal/server/SettingQuery.scala +++ b/main/src/main/scala/sbt/internal/server/SettingQuery.scala @@ -51,7 +51,7 @@ object SettingQuery { index: KeyIndex, currentBuild: URI, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]] + keyMap: Map[String, AttributeKey[?]] ): Parser[Seq[Parser[ParsedKey]]] = { for { rawProject <- projectRef(index, currentBuild) @@ -69,7 +69,7 @@ object SettingQuery { index: KeyIndex, currentBuild: URI, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], data: Settings[Scope] ): Parser[ParsedKey] = scopedKeyFull(index, currentBuild, defaultConfigs, keyMap) flatMap { choices => @@ -80,12 +80,12 @@ object SettingQuery { index: KeyIndex, currentBuild: URI, defaultConfigs: Option[ResolvedReference] => Seq[String], - keyMap: Map[String, AttributeKey[_]], + keyMap: Map[String, AttributeKey[?]], data: Settings[Scope] - ): Parser[ScopedKey[_]] = + ): Parser[ScopedKey[?]] = scopedKeySelected(index, currentBuild, defaultConfigs, keyMap, data).map(_.key) - def scopedKeyParser(structure: BuildStructure): Parser[ScopedKey[_]] = + def scopedKeyParser(structure: BuildStructure): Parser[ScopedKey[?]] = scopedKey( structure.index.keyIndex, structure.root, @@ -97,11 +97,11 @@ object SettingQuery { def getSettingValue[A](structure: BuildStructure, key: Def.ScopedKey[A]): Either[String, A] = structure.data .get(key.scope, key.key) - .toRight(s"Key ${Def displayFull key} not found") + .toRight(s"Key ${Def.displayFull(key)} not found") .flatMap { - case _: Task[_] => Left(s"Key ${Def displayFull key} is a task, can only query settings") + case _: Task[_] => Left(s"Key ${Def.displayFull(key)} is a task, can only query settings") case _: InputTask[_] => - Left(s"Key ${Def displayFull key} is an input task, can only query settings") + Left(s"Key ${Def.displayFull(key)} is an input task, can only query settings") case x => Right(x) } diff --git a/main/src/main/scala/sbt/nio/FileStamp.scala b/main/src/main/scala/sbt/nio/FileStamp.scala index 5ebba247b..a2a066456 100644 --- a/main/src/main/scala/sbt/nio/FileStamp.scala +++ b/main/src/main/scala/sbt/nio/FileStamp.scala @@ -177,9 +177,9 @@ object FileStamp { jsOpt match { case Some(js) => unbuilder.beginObject(js) - val hashes = unbuilder.readField("hashes")(seqPathHashJsonFormatter) + val hashes = unbuilder.readField("hashes")(using seqPathHashJsonFormatter) val lastModifieds = - unbuilder.readField("lastModifiedTimes")(seqPathLastModifiedJsonFormatter) + unbuilder.readField("lastModifiedTimes")(using seqPathLastModifiedJsonFormatter) unbuilder.endObject() hashes ++ lastModifieds case None => diff --git a/main/src/main/scala/sbt/nio/Settings.scala b/main/src/main/scala/sbt/nio/Settings.scala index 9dfc04af5..e7f7462a0 100644 --- a/main/src/main/scala/sbt/nio/Settings.scala +++ b/main/src/main/scala/sbt/nio/Settings.scala @@ -31,10 +31,10 @@ import java.io.File import xsbti.VirtualFileRef private[sbt] object Settings { - private[sbt] def inject(transformed: Seq[Def.Setting[_]]): Seq[Def.Setting[_]] = { - val definedSettings = new java.util.HashMap[Def.ScopedKey[_], VectorBuilder[Def.Setting[_]]] + private[sbt] def inject(transformed: Seq[Def.Setting[?]]): Seq[Def.Setting[?]] = { + val definedSettings = new java.util.HashMap[Def.ScopedKey[?], VectorBuilder[Def.Setting[?]]] val fileOutputScopes = transformed.flatMap { s => - val list = new VectorBuilder[Def.Setting[_]] + val list = new VectorBuilder[Def.Setting[?]] definedSettings.putIfAbsent(s.key, list) match { case null => list += s case l => l += s @@ -50,7 +50,7 @@ private[sbt] object Settings { (definedSettings.get(setting.key) match { case null => Vector(setting) case set => setting +: set.result() - }): Seq[Def.Setting[_]] + }): Seq[Def.Setting[?]] } } } @@ -69,9 +69,9 @@ private[sbt] object Settings { */ @nowarn private def maybeAddOutputsAndFileStamps( - setting: Def.Setting[_], + setting: Def.Setting[?], fileOutputScopes: Set[Scope] - ): List[Def.Setting[_]] = { + ): List[Def.Setting[?]] = { setting.key.key.tag match { case tag: KeyTag.Task[?] => if pathClass.isAssignableFrom(tag.typeArg) then addOutputAndStampTasks[Path](setting) @@ -92,9 +92,9 @@ private[sbt] object Settings { @nowarn private def addDefaultTasks( - setting: Def.Setting[_], + setting: Def.Setting[?], fileOutputScopes: Set[Scope] - ): List[Def.Setting[_]] = { + ): List[Def.Setting[?]] = { val scope = setting.key.scope.copy(task = Select(setting.key.key)) if (fileOutputScopes.contains(scope)) { val sk = setting.asInstanceOf[Def.Setting[Task[Any]]].key @@ -107,8 +107,8 @@ private[sbt] object Settings { @nowarn private def addOutputAndStampTasks[T: JsonFormat: ToSeqPath]( - setting: Def.Setting[_] - ): List[Def.Setting[_]] = { + setting: Def.Setting[?] + ): List[Def.Setting[?]] = { val sk = setting.asInstanceOf[Def.Setting[Task[T]]].key val taskKey = sk.scope / TaskKey(sk.key) // We create a previous reference so that clean automatically works without the @@ -121,7 +121,7 @@ private[sbt] object Settings { outputsAndStamps(taskKey) } - private[sbt] val inject: Def.ScopedKey[_] => Seq[Def.Setting[_]] = scopedKey => + private[sbt] val inject: Def.ScopedKey[?] => Seq[Def.Setting[?]] = scopedKey => scopedKey.key match { case transitiveDynamicInputs.key => scopedKey.scope.task.toOption.toSeq.map { key => @@ -155,7 +155,7 @@ private[sbt] object Settings { * @return a task definition that retrieves the file input files and their attributes scoped * to a particular task. */ - private[sbt] def inputPathSettings(setting: Def.Setting[_]): Seq[Def.Setting[_]] = { + private[sbt] def inputPathSettings(setting: Def.Setting[?]): Seq[Def.Setting[?]] = { val scopedKey = setting.key val scope = scopedKey.scope (scope / Keys.allInputPathsAndAttributes := { @@ -174,7 +174,7 @@ private[sbt] object Settings { }) :: fileStamps(scopedKey) :: allFilesImpl(scope) :: changedInputFilesImpl(scope) } - private val seqClass = classOf[Seq[_]] + private val seqClass = classOf[Seq[?]] private val pathClass = classOf[Path] private val fileClass = classOf[File] private val virtualFileRefClass = classOf[VirtualFileRef] @@ -186,7 +186,7 @@ private[sbt] object Settings { * @param scope the key whose file inputs we are seeking * @return a task definition that retrieves all of the input paths scoped to the input key. */ - private def allFilesImpl(scope: Scope): Def.Setting[_] = { + private def allFilesImpl(scope: Scope): Def.Setting[?] = { addTaskDefinition(scope / Keys.allInputFiles := { val filter = (scope / fileInputIncludeFilter).value && !(scope / fileInputExcludeFilter).value @@ -205,7 +205,7 @@ private[sbt] object Settings { * @param scope the scope corresponding to the task whose fileInputs we are seeking * @return a task definition that retrieves the changed input files scoped to the key. */ - private def changedInputFilesImpl(scope: Scope): List[Def.Setting[_]] = + private def changedInputFilesImpl(scope: Scope): List[Def.Setting[?]] = changedFilesImpl(scope, changedInputFiles, inputFileStamps) :: (scope / watchForceTriggerOnAnyChange := { (scope / watchForceTriggerOnAnyChange).?.value match { @@ -218,7 +218,7 @@ private[sbt] object Settings { scope: Scope, changeKey: TaskKey[Seq[(Path, FileStamp)] => FileChanges], stampKey: TaskKey[Seq[(Path, FileStamp)]] - ): Def.Setting[_] = + ): Def.Setting[?] = addTaskDefinition(scope / changeKey := { val current = (scope / stampKey).value changedFiles(_, current) @@ -260,7 +260,7 @@ private[sbt] object Settings { * @param scope the scope to add the custom clean * @return a task specific clean implementation */ - private[sbt] def cleanImpl(scope: Scope): Def.Setting[_] = addTaskDefinition { + private[sbt] def cleanImpl(scope: Scope): Def.Setting[?] = addTaskDefinition { scope / sbt.Keys.clean := Clean.task(scope, full = false).value } @@ -271,7 +271,7 @@ private[sbt] object Settings { * @return a task specific clean implementation */ @nowarn - private[sbt] def cleanImpl[T: JsonFormat: ToSeqPath](taskKey: TaskKey[T]): Def.Setting[_] = { + private[sbt] def cleanImpl[T: JsonFormat: ToSeqPath](taskKey: TaskKey[T]): Def.Setting[?] = { val taskScope = taskKey.scope.rescope(taskKey.key) addTaskDefinition( taskScope / sbt.Keys.clean := @@ -296,7 +296,7 @@ private[sbt] object Settings { * @return a task definition that retrieves the input files and their file stamps scoped to the * input key. */ - private[sbt] def fileStamps(scopedKey: Def.ScopedKey[_]): Def.Setting[_] = { + private[sbt] def fileStamps(scopedKey: Def.ScopedKey[?]): Def.Setting[?] = { import scala.collection.parallel.CollectionConverters.* val scope = scopedKey.scope addTaskDefinition(scope / Keys.inputFileStamps := { @@ -327,13 +327,13 @@ private[sbt] object Settings { @nowarn private def outputsAndStamps[T: JsonFormat: ToSeqPath]( taskKey: TaskKey[T] - ): List[Def.Setting[_]] = { + ): List[Def.Setting[?]] = { val scope = taskKey.scope.rescope(taskKey.key) val changes = changedFilesImpl(scope, changedOutputFiles, outputFileStamps) :: Nil allOutputPathsImpl(scope) :: outputFileStampsImpl(scope) :: cleanImpl(taskKey) :: changes } - private def allOutputPathsImpl(scope: Scope): Def.Setting[_] = + private def allOutputPathsImpl(scope: Scope): Def.Setting[?] = addTaskDefinition(scope / allOutputFiles := { val filter = (scope / fileOutputIncludeFilter).value && !(scope / fileOutputExcludeFilter).value @@ -359,7 +359,7 @@ private[sbt] object Settings { } }) - private def outputFileStampsImpl(scope: Scope): Def.Setting[_] = + private def outputFileStampsImpl(scope: Scope): Def.Setting[?] = addTaskDefinition(scope / outputFileStamps := { val stamper: Path => Option[FileStamp] = (scope / outputFileStamper).value match { case LastModified => FileStamp.lastModified diff --git a/main/src/main/scala/sbt/nio/Watch.scala b/main/src/main/scala/sbt/nio/Watch.scala index 890967802..3a44e65ea 100644 --- a/main/src/main/scala/sbt/nio/Watch.scala +++ b/main/src/main/scala/sbt/nio/Watch.scala @@ -286,7 +286,7 @@ object Watch { // For now leave this private in case this isn't the best unapply type signature since it can't // be evolved in a binary compatible way. object Run { - def apply(commands: String*): Run = new Watch.Run(commands: _*) + def apply(commands: String*): Run = new Watch.Run(commands*) def unapply(r: Run): Option[List[Exec]] = Some(r.commands.toList.map(Exec(_, None))) } @@ -616,7 +616,7 @@ object Watch { defaultOnTriggerMessage(count, path, commands) }.label("Watch.clearScreenOnTrigger") - private[sbt] def defaults: Seq[Def.Setting[_]] = Seq( + private[sbt] def defaults: Seq[Def.Setting[?]] = Seq( sbt.Keys.watchAntiEntropy :== Watch.defaultAntiEntropy, watchAntiEntropyRetentionPeriod :== Watch.defaultAntiEntropyRetentionPeriod, watchLogLevel :== Level.Info, diff --git a/main/src/main/scala/sbt/plugins/CorePlugin.scala b/main/src/main/scala/sbt/plugins/CorePlugin.scala index 3df867643..f843ea127 100644 --- a/main/src/main/scala/sbt/plugins/CorePlugin.scala +++ b/main/src/main/scala/sbt/plugins/CorePlugin.scala @@ -21,8 +21,8 @@ object CorePlugin extends AutoPlugin { override def trigger = allRequirements override def requires = empty - override lazy val projectSettings: Seq[Setting[_]] = + override lazy val projectSettings: Seq[Setting[?]] = Defaults.coreDefaultSettings - override lazy val globalSettings: Seq[Setting[_]] = + override lazy val globalSettings: Seq[Setting[?]] = Defaults.globalSbtCore } diff --git a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala index 6d3bee3b3..17d039574 100644 --- a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala +++ b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala @@ -62,7 +62,7 @@ object DependencyTreeSettings { * MiniDependencyTreePlugin includes these settings for Compile and Test scopes * to provide dependencyTree task. */ - lazy val baseBasicReportingSettings: Seq[Def.Setting[_]] = + lazy val baseBasicReportingSettings: Seq[Def.Setting[?]] = Seq( dependencyTreeCrossProjectId := CrossVersion(scalaVersion.value, scalaBinaryVersion.value)( projectID.value @@ -78,7 +78,10 @@ object DependencyTreeSettings { if (dependencyTreeIncludeScalaLibrary.value) g else GraphTransformations.ignoreScalaLibrary(sv, g) }, - dependencyTreeModuleGraphStore := (dependencyTreeModuleGraph0 storeAs dependencyTreeModuleGraphStore triggeredBy dependencyTreeModuleGraph0).value, + dependencyTreeModuleGraphStore := dependencyTreeModuleGraph0 + .storeAs(dependencyTreeModuleGraphStore) + .triggeredBy(dependencyTreeModuleGraph0) + .value, ) ++ { renderingTaskSettings(dependencyTree) :+ { dependencyTree / asString := { @@ -90,7 +93,7 @@ object DependencyTreeSettings { /** * This is the maximum strength settings for DependencyTreePlugin. */ - lazy val baseFullReportingSettings: Seq[Def.Setting[_]] = + lazy val baseFullReportingSettings: Seq[Def.Setting[?]] = Seq( // browse dependencyBrowseGraphTarget := { target.value / "browse-dependency-graph" }, @@ -155,16 +158,16 @@ object DependencyTreeSettings { def renderingAlternatives: Seq[(TaskKey[Unit], ModuleGraph => String)] = Seq( dependencyList -> rendering.FlatList.render(_.id.idString), - dependencyStats -> rendering.Statistics.renderModuleStatsList _, - dependencyLicenseInfo -> rendering.LicenseInfo.render _ + dependencyStats -> rendering.Statistics.renderModuleStatsList, + dependencyLicenseInfo -> rendering.LicenseInfo.render ) - def renderingTaskSettings(key: TaskKey[Unit], renderer: ModuleGraph => String): Seq[Setting[_]] = + def renderingTaskSettings(key: TaskKey[Unit], renderer: ModuleGraph => String): Seq[Setting[?]] = renderingTaskSettings(key) :+ { key / asString := renderer(dependencyTreeModuleGraph0.value) } - def renderingTaskSettings(key: TaskKey[Unit]): Seq[Setting[_]] = + def renderingTaskSettings(key: TaskKey[Unit]): Seq[Setting[?]] = Seq( key := { val s = streams.value diff --git a/main/src/main/scala/sbt/plugins/Giter8TemplatePlugin.scala b/main/src/main/scala/sbt/plugins/Giter8TemplatePlugin.scala index 51e60575b..9e004b6d2 100644 --- a/main/src/main/scala/sbt/plugins/Giter8TemplatePlugin.scala +++ b/main/src/main/scala/sbt/plugins/Giter8TemplatePlugin.scala @@ -20,7 +20,7 @@ object Giter8TemplatePlugin extends AutoPlugin { override def requires = CorePlugin override def trigger = allRequirements - override lazy val globalSettings: Seq[Setting[_]] = + override lazy val globalSettings: Seq[Setting[?]] = Seq( templateResolverInfos += TemplateResolverInfo( @@ -28,7 +28,7 @@ object Giter8TemplatePlugin extends AutoPlugin { "org.scala-sbt.sbt-giter8-resolver", "sbt-giter8-resolver", "0.16.2" - ) cross CrossVersion.binary, + ).cross(CrossVersion.binary), "sbtgiter8resolver.Giter8TemplateResolver" ) ) diff --git a/main/src/main/scala/sbt/plugins/IvyPlugin.scala b/main/src/main/scala/sbt/plugins/IvyPlugin.scala index da877a72a..2d4a31b58 100644 --- a/main/src/main/scala/sbt/plugins/IvyPlugin.scala +++ b/main/src/main/scala/sbt/plugins/IvyPlugin.scala @@ -27,9 +27,9 @@ object IvyPlugin extends AutoPlugin { override def requires = CorePlugin override def trigger = allRequirements - override lazy val globalSettings: Seq[Setting[_]] = + override lazy val globalSettings: Seq[Setting[?]] = Defaults.globalIvyCore - override lazy val projectSettings: Seq[Setting[_]] = + override lazy val projectSettings: Seq[Setting[?]] = Classpaths.ivyPublishSettings ++ Classpaths.ivyBaseSettings } diff --git a/main/src/main/scala/sbt/plugins/JUnitXmlReportPlugin.scala b/main/src/main/scala/sbt/plugins/JUnitXmlReportPlugin.scala index d8eaa593b..5ce7d7a72 100644 --- a/main/src/main/scala/sbt/plugins/JUnitXmlReportPlugin.scala +++ b/main/src/main/scala/sbt/plugins/JUnitXmlReportPlugin.scala @@ -40,7 +40,7 @@ object JUnitXmlReportPlugin extends AutoPlugin { val testReportsDirectory = settingKey[File]("Directory for outputting junit test reports.").withRank(AMinusSetting) - lazy val testReportSettings: Seq[Setting[_]] = Seq( + lazy val testReportSettings: Seq[Setting[?]] = Seq( testReportsDirectory := target.value / (prefix(configuration.value.name) + "reports"), testListeners += new JUnitXmlTestsListener( testReportsDirectory.value, @@ -53,7 +53,7 @@ object JUnitXmlReportPlugin extends AutoPlugin { import autoImport._ @nowarn - override lazy val projectSettings: Seq[Setting[_]] = + override lazy val projectSettings: Seq[Setting[?]] = inConfig(Test)(testReportSettings) ++ inConfig(IntegrationTest)(testReportSettings) } diff --git a/main/src/main/scala/sbt/plugins/JvmPlugin.scala b/main/src/main/scala/sbt/plugins/JvmPlugin.scala index e4b134d33..2fd0f4081 100644 --- a/main/src/main/scala/sbt/plugins/JvmPlugin.scala +++ b/main/src/main/scala/sbt/plugins/JvmPlugin.scala @@ -31,13 +31,13 @@ object JvmPlugin extends AutoPlugin { override def requires = IvyPlugin override def trigger = allRequirements - override lazy val globalSettings: Seq[Setting[_]] = + override lazy val globalSettings: Seq[Setting[?]] = Defaults.globalJvmCore - override lazy val buildSettings: Seq[Setting[_]] = + override lazy val buildSettings: Seq[Setting[?]] = Defaults.buildLevelJvmSettings - override lazy val projectSettings: Seq[Setting[_]] = + override lazy val projectSettings: Seq[Setting[?]] = Defaults.runnerSettings ++ Defaults.paths ++ Classpaths.jvmPublishSettings ++ diff --git a/main/src/main/scala/sbt/plugins/MiniDependencyTreePlugin.scala b/main/src/main/scala/sbt/plugins/MiniDependencyTreePlugin.scala index d1d05f96d..c042cec10 100644 --- a/main/src/main/scala/sbt/plugins/MiniDependencyTreePlugin.scala +++ b/main/src/main/scala/sbt/plugins/MiniDependencyTreePlugin.scala @@ -18,10 +18,10 @@ object MiniDependencyTreePlugin extends AutoPlugin { import autoImport._ override def trigger: PluginTrigger = AllRequirements - override def globalSettings: Seq[Def.Setting[_]] = Seq( + override def globalSettings: Seq[Def.Setting[?]] = Seq( dependencyTreeIncludeScalaLibrary := false ) - override def projectSettings: Seq[Def.Setting[_]] = + override def projectSettings: Seq[Def.Setting[?]] = DependencyTreeSettings.coreSettings ++ inConfig(Compile)(DependencyTreeSettings.baseBasicReportingSettings) ++ inConfig(Test)(DependencyTreeSettings.baseBasicReportingSettings) diff --git a/main/src/main/scala/sbt/plugins/SbtPlugin.scala b/main/src/main/scala/sbt/plugins/SbtPlugin.scala index b1ebb9046..1128c0269 100644 --- a/main/src/main/scala/sbt/plugins/SbtPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SbtPlugin.scala @@ -15,7 +15,7 @@ import sbt.Keys.* object SbtPlugin extends AutoPlugin: override def requires = ScriptedPlugin - override lazy val projectSettings: Seq[Setting[_]] = Seq( + override lazy val projectSettings: Seq[Setting[?]] = Seq( sbtPlugin := true, pluginCrossBuild / sbtVersion := { scalaBinaryVersion.value match diff --git a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala index 0a396bf3c..faf286b36 100644 --- a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala @@ -23,14 +23,14 @@ object SemanticdbPlugin extends AutoPlugin { override def requires = JvmPlugin override def trigger = allRequirements - override lazy val globalSettings: Seq[Def.Setting[_]] = Seq( + override lazy val globalSettings: Seq[Def.Setting[?]] = Seq( semanticdbEnabled := SysProp.semanticdb, semanticdbIncludeInJar := false, semanticdbOptions := List(), semanticdbVersion := "4.9.9" ) - override lazy val projectSettings: Seq[Def.Setting[_]] = Seq( + override lazy val projectSettings: Seq[Def.Setting[?]] = Seq( semanticdbCompilerPlugin := { val v = semanticdbVersion.value ("org.scalameta" % "semanticdb-scalac" % v).cross(CrossVersion.full) @@ -53,7 +53,7 @@ object SemanticdbPlugin extends AutoPlugin { inConfig(Compile)(configurationSettings) ++ inConfig(Test)(configurationSettings) - lazy val configurationSettings: Seq[Def.Setting[_]] = List( + lazy val configurationSettings: Seq[Def.Setting[?]] = List( semanticdbTargetRoot := { val in = semanticdbIncludeInJar.value if (in) classDirectory.value @@ -90,7 +90,7 @@ object SemanticdbPlugin extends AutoPlugin { ) @deprecated("use configurationSettings only", "1.5.0") - lazy val testSettings: Seq[Def.Setting[_]] = List() + lazy val testSettings: Seq[Def.Setting[?]] = List() def targetRootOptions(scalaVersion: String, targetRoot: File): Seq[String] = { if (ScalaInstance.isDotty(scalaVersion)) { @@ -104,6 +104,6 @@ object SemanticdbPlugin extends AutoPlugin { def ancestors(configs: Vector[Configuration]): Vector[Configuration] = configs ++ configs.flatMap(conf => ancestors(conf.extendsConfigs)) - ScopeFilter(configurations = inConfigurations(ancestors(config.extendsConfigs): _*)) + ScopeFilter(configurations = inConfigurations(ancestors(config.extendsConfigs)*)) } } diff --git a/main/src/test/scala/Delegates.scala b/main/src/test/scala/Delegates.scala index 036272639..5986e8747 100644 --- a/main/src/test/scala/Delegates.scala +++ b/main/src/test/scala/Delegates.scala @@ -134,7 +134,7 @@ object Delegates extends Properties { ) ) - def allAxes(f: (Scope, Seq[Scope], Scope => ScopeAxis[_]) => hedgehog.Result): Property = + def allAxes(f: (Scope, Seq[Scope], Scope => ScopeAxis[?]) => hedgehog.Result): Property = keysGen.forAll.map { keys => allDelegates(keys) { (s, ds) => all(List(f(s, ds, _.project), f(s, ds, _.config), f(s, ds, _.task), f(s, ds, _.extra))) @@ -149,7 +149,7 @@ object Delegates extends Properties { .log("Delegates:\n\t" + delegates.map(scope => Scope.display(scope, "_")).mkString("\n\t")) }.toList) - def alwaysZero(s: Scope, ds: Seq[Scope], axis: Scope => ScopeAxis[_]): hedgehog.Result = + def alwaysZero(s: Scope, ds: Seq[Scope], axis: Scope => ScopeAxis[?]): hedgehog.Result = assert(axis(s) != Zero).or( all(ds.map { d => axis(d) ==== Zero diff --git a/main/src/test/scala/ParseKeySpec.scala b/main/src/test/scala/ParseKeySpec.scala index 885538c26..4f255784d 100644 --- a/main/src/test/scala/ParseKeySpec.scala +++ b/main/src/test/scala/ParseKeySpec.scala @@ -97,7 +97,7 @@ object ParseKeySpec extends Properties { val showZeroConfig = hasAmbiguousLowercaseAxes(key, structure) parseCheck(structure, key, mask, showZeroConfig)(sk => (sk.scope.config ==== resolvedConfig) or (sk.scope ==== Scope.GlobalScope) - ).log(s"Expected configuration: ${resolvedConfig map (_.name)}") + ).log(s"Expected configuration: ${resolvedConfig.map(_.name)}") } val arbStructure: Gen[Structure] = @@ -118,7 +118,7 @@ object ParseKeySpec extends Properties { } yield Def.setting(ScopedKey(scope, t.key), Def.value("")) } - final case class StructureKeyMask(structure: Structure, key: ScopedKey[_], mask: ScopeMask) + final case class StructureKeyMask(structure: Structure, key: ScopedKey[?], mask: ScopeMask) val arbStructureKeyMask: Gen[StructureKeyMask] = (for { @@ -151,7 +151,7 @@ object ParseKeySpec extends Properties { checkName.getOrElse(true) } - def resolve(structure: Structure, key: ScopedKey[_], mask: ScopeMask): ScopedKey[_] = + def resolve(structure: Structure, key: ScopedKey[?], mask: ScopeMask): ScopedKey[?] = ScopedKey( Resolve(structure.extra, Select(structure.current), key.key, mask)(key.scope), key.key @@ -159,10 +159,10 @@ object ParseKeySpec extends Properties { def parseCheck( structure: Structure, - key: ScopedKey[_], + key: ScopedKey[?], mask: ScopeMask, showZeroConfig: Boolean = false, - )(f: ScopedKey[_] => hedgehog.Result): hedgehog.Result = { + )(f: ScopedKey[?] => hedgehog.Result): hedgehog.Result = { val s = displayMasked(key, mask, showZeroConfig) val parser = makeParser(structure) val parsed = Parser.result(parser, s).left.map(_().toString) @@ -186,7 +186,7 @@ object ParseKeySpec extends Properties { // then a scoped key like `foo//foo/name` would render as `foo/name` // which would be interpreted as `foo/Zero/Zero/name` // so we mitigate this by explicitly displaying the configuration axis set to Zero - def hasAmbiguousLowercaseAxes(key: ScopedKey[_], structure: Structure): Boolean = { + def hasAmbiguousLowercaseAxes(key: ScopedKey[?], structure: Structure): Boolean = { val label = key.key.label val allProjects = for { uri <- structure.keyIndex.buildURIs diff --git a/main/src/test/scala/PluginCommandTest.scala b/main/src/test/scala/PluginCommandTest.scala index 06e1cc7c5..55268b6d0 100644 --- a/main/src/test/scala/PluginCommandTest.scala +++ b/main/src/test/scala/PluginCommandTest.scala @@ -71,7 +71,7 @@ object FakeState { val outBuffer = new ByteArrayOutputStream val logFile = File.createTempFile("sbt", ".log") try { - val state = FakeState(logFile, enabledPlugins: _*) + val state = FakeState(logFile, enabledPlugins*) Terminal.withOut(new PrintStream(outBuffer, true)) { MainLoop.processCommand(Exec(input, None), state) } @@ -87,7 +87,7 @@ object FakeState { val base = new File("").getAbsoluteFile val testProject = Project("test-project", base).setAutoPlugins(plugins) - val settings: Seq[Def.Setting[_]] = Nil + val settings: Seq[Def.Setting[?]] = Nil val currentProject = Map(testProject.base.toURI -> testProject.id) val currentEval: () => Eval = () => Load.mkEval(Nil, base, Nil) @@ -99,7 +99,7 @@ object FakeState { val (cMap, data: Settings[Scope]) = Def.makeWithCompiledMap(settings)(using delegates, scopeLocal, Def.showFullKey) - val extra: KeyIndex => BuildUtil[_] = (keyIndex) => + val extra: KeyIndex => BuildUtil[?] = (keyIndex) => BuildUtil(base.toURI, Map.empty, keyIndex, data) val structureIndex: StructureIndex = Load.structureIndex(data, settings, extra, Map.empty) diff --git a/main/src/test/scala/ProjectMacro.scala b/main/src/test/scala/ProjectMacro.scala index 3f47153c0..394a38f90 100644 --- a/main/src/test/scala/ProjectMacro.scala +++ b/main/src/test/scala/ProjectMacro.scala @@ -22,7 +22,7 @@ class ProjectDefs { // should not compile // def y = project - val z = project in new File("dir") + val z = (project in new File("dir")) val a: Project = project diff --git a/main/src/test/scala/sbt/internal/CrossJavaTest.scala b/main/src/test/scala/sbt/internal/CrossJavaTest.scala index b8dc89248..5d57bb50d 100644 --- a/main/src/test/scala/sbt/internal/CrossJavaTest.scala +++ b/main/src/test/scala/sbt/internal/CrossJavaTest.scala @@ -102,7 +102,7 @@ class CrossJavaTest extends AnyFunSuite with Diagrams { val conf = new SdkmanDiscoverConfig { override def candidates() = Vector("11.0.2.hs-adpt") } - val hs = CrossJava.expandJavaHomes(ListMap(conf.javaHomes: _*)) + val hs = CrossJava.expandJavaHomes(ListMap(conf.javaHomes*)) assert(hs.contains("11")) } diff --git a/main/src/test/scala/sbt/internal/TestBuild.scala b/main/src/test/scala/sbt/internal/TestBuild.scala index 85b833223..ee68dc371 100644 --- a/main/src/test/scala/sbt/internal/TestBuild.scala +++ b/main/src/test/scala/sbt/internal/TestBuild.scala @@ -61,7 +61,7 @@ abstract class TestBuild { current: ProjectRef, data: Settings[Scope], keyIndex: KeyIndex, - keyMap: Map[String, AttributeKey[_]] + keyMap: Map[String, AttributeKey[?]] ) { override def toString = env.toString + "\n" + "current: " + current + "\nSettings:\n\t" + showData + keyMap.keys @@ -85,7 +85,7 @@ abstract class TestBuild { ) } - lazy val allAttributeKeys: Set[AttributeKey[_]] = { + lazy val allAttributeKeys: Set[AttributeKey[?]] = { val x = data.data.values.flatMap(_.keys).toSet if (x.isEmpty) { sys.error("allAttributeKeys is empty") @@ -100,16 +100,16 @@ abstract class TestBuild { val taskAxesMappings = for ((scope, keys) <- data.data; key <- keys.keys) yield (ScopedKey(scope.copy(task = Zero), key), scope.task): ( - ScopedKey[_], - ScopeAxis[AttributeKey[_]] + ScopedKey[?], + ScopeAxis[AttributeKey[?]] ) val taskAxes = Relation.empty ++ taskAxesMappings - val zero = new HashSet[ScopedKey[_]] - val single = new HashSet[ScopedKey[_]] - val multi = new HashSet[ScopedKey[_]] + val zero = new HashSet[ScopedKey[?]] + val single = new HashSet[ScopedKey[?]] + val multi = new HashSet[ScopedKey[?]] for ((skey, tasks) <- taskAxes.forwardMap) { - def makeKey(task: ScopeAxis[AttributeKey[_]]) = + def makeKey(task: ScopeAxis[AttributeKey[?]]) = ScopedKey(skey.scope.copy(task = task), skey.key) val hasGlobal = tasks(Zero) if (hasGlobal) zero += skey @@ -140,7 +140,7 @@ abstract class TestBuild { def rootProject(uri: URI): String = buildMap(uri).root.id def inheritConfig(ref: ResolvedReference, config: ConfigKey) = projectFor(ref).confMap(config.name).extendsConfigs map toConfigKey - def inheritTask(task: AttributeKey[_]) = taskMap.get(task) match { + def inheritTask(task: AttributeKey[?]) = taskMap.get(task) match { case None => Vector() case Some(t) => t.delegates.toVector map getKey } @@ -163,7 +163,7 @@ abstract class TestBuild { c <- Zero +: p.configurations.map(c => Select(ConfigKey(c.name))) } yield Scope(project = ref, config = c, task = t, extra = Zero) } - def getKey: Taskk => AttributeKey[_] = _.key + def getKey: Taskk => AttributeKey[?] = _.key def toConfigKey: Configuration => ConfigKey = c => ConfigKey(c.name) case class Build(uri: URI, projects: Seq[Proj]) { override def toString = "Build " + uri.toString + " :\n " + projects.mkString("\n ") @@ -216,7 +216,7 @@ abstract class TestBuild { Gen.frequency1((1, gen map Select.apply), (1, Gen.constant(Zero))) def oneOrGlobal[T](gen: Seq[T]): Gen[ScopeAxis[T]] = orGlobal(oneOf(gen)) - def makeParser(structure: Structure): Parser[ScopedKey[_]] = { + def makeParser(structure: Structure): Parser[ScopedKey[?]] = { import structure._ def confs(uri: URI) = env.buildMap.get(uri).toList.flatMap { _.root.configurations.map(_.name) } @@ -228,7 +228,7 @@ abstract class TestBuild { Act.scopedKey(keyIndex, current, defaultConfs, keyMap, data) } - def structure(env: Env, settings: Seq[Setting[_]], current: ProjectRef): Structure = { + def structure(env: Env, settings: Seq[Setting[?]], current: ProjectRef): Structure = { val display = Def.showRelativeKey2(current) if (settings.isEmpty) { try { @@ -241,7 +241,7 @@ abstract class TestBuild { } val data = Def.makeWithCompiledMap(settings)(using env.delegates, const(Nil), display)._2 val keys = data.allKeys((s, key) => ScopedKey(s, key)) - val keyMap = keys.map(k => (k.key.label, k.key)).toMap[String, AttributeKey[_]] + val keyMap = keys.map(k => (k.key.label, k.key)).toMap[String, AttributeKey[?]] val projectsMap = env.builds.map(b => (b.uri, b.projects.map(_.id).toSet)).toMap val confs = for { b <- env.builds diff --git a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcNotificationMessageFormats.scala b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcNotificationMessageFormats.scala index f74643c9f..f5f3dcd66 100644 --- a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcNotificationMessageFormats.scala +++ b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcNotificationMessageFormats.scala @@ -12,7 +12,7 @@ import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } import sjsonnew.shaded.scalajson.ast.unsafe.JValue trait JsonRpcNotificationMessageFormats { - self: sbt.internal.util.codec.JValueFormats with sjsonnew.BasicJsonProtocol => + self: sbt.internal.util.codec.JValueFormats & sjsonnew.BasicJsonProtocol => implicit lazy val JsonRpcNotificationMessageFormat : JsonFormat[sbt.internal.protocol.JsonRpcNotificationMessage] = new JsonFormat[sbt.internal.protocol.JsonRpcNotificationMessage] { diff --git a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala index a87724dd1..63d6f47e7 100644 --- a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala +++ b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcRequestMessageFormats.scala @@ -12,7 +12,7 @@ import sjsonnew.shaded.scalajson.ast.unsafe.JValue import sjsonnew.{ Builder, DeserializationException, JsonFormat, Unbuilder, deserializationError } trait JsonRpcRequestMessageFormats { - self: sbt.internal.util.codec.JValueFormats with sjsonnew.BasicJsonProtocol => + self: sbt.internal.util.codec.JValueFormats & sjsonnew.BasicJsonProtocol => implicit lazy val JsonRpcRequestMessageFormat : JsonFormat[sbt.internal.protocol.JsonRpcRequestMessage] = new JsonFormat[sbt.internal.protocol.JsonRpcRequestMessage] { diff --git a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseErrorFormats.scala b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseErrorFormats.scala index 72211d131..2a6c1e579 100644 --- a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseErrorFormats.scala +++ b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseErrorFormats.scala @@ -12,7 +12,7 @@ import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } import sjsonnew.shaded.scalajson.ast.unsafe.JValue trait JsonRpcResponseErrorFormats { - self: sbt.internal.util.codec.JValueFormats with sjsonnew.BasicJsonProtocol => + self: sbt.internal.util.codec.JValueFormats & sjsonnew.BasicJsonProtocol => implicit lazy val JsonRpcResponseErrorFormat : JsonFormat[sbt.internal.protocol.JsonRpcResponseError] = new JsonFormat[sbt.internal.protocol.JsonRpcResponseError] { diff --git a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala index 1da1a4805..852ade796 100644 --- a/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala +++ b/protocol/src/main/scala/sbt/internal/protocol/codec/JsonRpcResponseMessageFormats.scala @@ -18,9 +18,8 @@ import _root_.sjsonnew.{ import sjsonnew.shaded.scalajson.ast.unsafe._ trait JsonRpcResponseMessageFormats { - self: sbt.internal.util.codec.JValueFormats - with sbt.internal.protocol.codec.JsonRpcResponseErrorFormats - with sjsonnew.BasicJsonProtocol => + self: sbt.internal.util.codec.JValueFormats & + sbt.internal.protocol.codec.JsonRpcResponseErrorFormats & sjsonnew.BasicJsonProtocol => implicit lazy val JsonRpcResponseMessageFormat : JsonFormat[sbt.internal.protocol.JsonRpcResponseMessage] = new JsonFormat[sbt.internal.protocol.JsonRpcResponseMessage] { diff --git a/run/src/main/scala/sbt/Fork.scala b/run/src/main/scala/sbt/Fork.scala index 4f240ab48..e4145980b 100644 --- a/run/src/main/scala/sbt/Fork.scala +++ b/run/src/main/scala/sbt/Fork.scala @@ -65,9 +65,9 @@ final class Fork(val commandName: String, val runnerClass: Option[String]) { if (Fork.shouldUseArgumentsFile(options)) new JProcessBuilder(executable, Fork.createArgumentsFile(options)) else - new JProcessBuilder(command.toArray: _*) - workingDirectory foreach (jpb directory _) - environment foreach { case (k, v) => jpb.environment.put(k, v) } + new JProcessBuilder(command.toArray*) + workingDirectory.foreach(jpb.directory(_)) + environment.foreach { case (k, v) => jpb.environment.put(k, v) } if (connectInput) { jpb.redirectInput(Redirect.INHERIT) () diff --git a/run/src/test/scala/sbt/ForkTest.scala b/run/src/test/scala/sbt/ForkTest.scala index 4a2ad0125..4ea3c9675 100644 --- a/run/src/test/scala/sbt/ForkTest.scala +++ b/run/src/test/scala/sbt/ForkTest.scala @@ -33,7 +33,7 @@ object ForkTest extends Properties("Fork") { lazy val genRelClasspath = nonEmptyListOf(path) lazy val requiredEntries = - IO.classLocationPath(classOf[scala.Option[_]]).toFile :: + IO.classLocationPath(classOf[scala.Option[?]]).toFile :: IO.classLocationPath(classOf[sbt.exit.type]).toFile :: Nil lazy val mainAndArgs = diff --git a/sbt-remote-cache/src/main/scala/sbt/internal/GrpcActionCacheStore.scala b/sbt-remote-cache/src/main/scala/sbt/internal/GrpcActionCacheStore.scala index ee178df78..ed9b7b3c8 100644 --- a/sbt-remote-cache/src/main/scala/sbt/internal/GrpcActionCacheStore.scala +++ b/sbt-remote-cache/src/main/scala/sbt/internal/GrpcActionCacheStore.scala @@ -175,7 +175,7 @@ class GrpcActionCacheStore( val responses = result.getResponsesList().asScala.toList // do not assume responses to come in order val lookupResponse: Map[Digest, BatchUpdateBlobsResponse.Response] = - Map(responses.map(res => toDigest(res.getDigest()) -> res): _*) + Map(responses.map(res => toDigest(res.getDigest()) -> res)*) blobs.flatMap: blob => val d = Digest(blob) if lookupResponse.contains(d) then @@ -192,7 +192,7 @@ class GrpcActionCacheStore( if allOk then // do not assume the responses to come in order val lookupResponse: Map[Digest, BatchReadBlobsResponse.Response] = - Map(blobs.map(res => toDigest(res.getDigest) -> res): _*) + Map(blobs.map(res => toDigest(res.getDigest) -> res)*) refs.map: r => val digest = Digest(r) val blob = lookupResponse(digest) diff --git a/sbt-remote-cache/src/main/scala/sbt/plugins/RemoteCachePlugin.scala b/sbt-remote-cache/src/main/scala/sbt/plugins/RemoteCachePlugin.scala index b9c29b6c2..a6466f7be 100644 --- a/sbt-remote-cache/src/main/scala/sbt/plugins/RemoteCachePlugin.scala +++ b/sbt-remote-cache/src/main/scala/sbt/plugins/RemoteCachePlugin.scala @@ -8,7 +8,7 @@ import sbt.internal.GrpcActionCacheStore object RemoteCachePlugin extends AutoPlugin: override def trigger = AllRequirements override def requires = JvmPlugin - override def globalSettings: Seq[Def.Setting[_]] = Seq( + override def globalSettings: Seq[Def.Setting[?]] = Seq( cacheStores := { val orig = cacheStores.value val remoteOpt = remoteCache.value diff --git a/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala b/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala index aa76a809e..fff4afb38 100644 --- a/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala +++ b/scripted-sbt/src/main/scala/sbt/scriptedtest/ScriptedTests.scala @@ -581,7 +581,7 @@ class ScriptedRunner { launcherJar.getName.dropWhile(!_.isDigit).dropRight(".jar".length) case RunFromSourceBased(_, sbtVersion, _) => sbtVersion } - val accept = isTestCompatible(baseDir, sbtVersion) _ + val accept = isTestCompatible(baseDir, sbtVersion) // The scripted tests mapped to the inputs that the user wrote after `scripted`. val scriptedTests = get(tests, baseDir, accept, logger).map(st => (st.group, st.name)) @@ -714,7 +714,7 @@ private[sbt] final class ListTests( log.warn(s"Tests skipped in group $groupName:") skipped.foreach(testName => log.warn(s" ${testName.getName}")) } - Set(included.map(_.getName): _*) + Set(included.map(_.getName)*) } } } diff --git a/server-test/src/test/scala/testpkg/BuildServerTest.scala b/server-test/src/test/scala/testpkg/BuildServerTest.scala index 7952e21b8..857d3b25d 100644 --- a/server-test/src/test/scala/testpkg/BuildServerTest.scala +++ b/server-test/src/test/scala/testpkg/BuildServerTest.scala @@ -33,9 +33,9 @@ class BuildServerTest extends AbstractServerTest { test("build/initialize") { val id = initializeRequest() assert(svr.waitForString(10.seconds) { s => - (s contains s""""id":"$id"""") && - (s contains """"resourcesProvider":true""") && - (s contains """"outputPathsProvider":true""") + s.contains(s""""id":"$id"""") && + s.contains(""""resourcesProvider":true""") && + s.contains(""""outputPathsProvider":true""") }) } @@ -93,7 +93,7 @@ class BuildServerTest extends AbstractServerTest { "project/src/main/scala-3", s"project/src/main/scala-sbt-${TestProperties.version}", "project/src/main/scala/", - "target/out/jvm/scala-3.3.4/buildserver-build/src_managed/main" + s"target/out/jvm/scala-${TestProperties.scalaVersion}/buildserver-build/src_managed/main" ).map(rel => new File(svr.baseDirectory.getAbsoluteFile, rel).toURI).sorted assert(sources == expectedSources) } diff --git a/server-test/src/test/scala/testpkg/EventsTest.scala b/server-test/src/test/scala/testpkg/EventsTest.scala index 1ee0d6d4b..f689c1778 100644 --- a/server-test/src/test/scala/testpkg/EventsTest.scala +++ b/server-test/src/test/scala/testpkg/EventsTest.scala @@ -21,7 +21,7 @@ class EventsTest extends AbstractServerTest { s"""{ "jsonrpc": "2.0", "id": $id, "method": "sbt/exec", "params": { "commandLine": "hello" } }""" ) assert(svr.waitForString(10.seconds) { s => - (s contains s""""id":$id""") && (s contains """"error":""") + s.contains(s""""id":$id""") && s.contains(""""error":""") }) } @@ -37,7 +37,7 @@ class EventsTest extends AbstractServerTest { s"""{ "jsonrpc": "2.0", "id":$cancelID, "method": "sbt/cancelRequest", "params": { "id": "$invalidID" } }""" ) assert(svr.waitForString(20.seconds) { s => - (s contains """"error":{"code":-32800""") + s.contains(""""error":{"code":-32800""") }) } diff --git a/server-test/src/test/scala/testpkg/HandshakeTest.scala b/server-test/src/test/scala/testpkg/HandshakeTest.scala index fa726a28e..5f7a8e711 100644 --- a/server-test/src/test/scala/testpkg/HandshakeTest.scala +++ b/server-test/src/test/scala/testpkg/HandshakeTest.scala @@ -18,7 +18,7 @@ class HandshakeTest extends AbstractServerTest { """{ "jsonrpc": "2.0", "id": "3", "method": "sbt/setting", "params": { "setting": "root/name" } }""" ) assert(svr.waitForString(10.seconds) { s => - s contains """"id":"3"""" + s.contains(""""id":"3"""") }) } @@ -27,7 +27,7 @@ class HandshakeTest extends AbstractServerTest { """{ "jsonrpc": "2.0", "id": 3, "method": "sbt/setting", "params": { "setting": "root/name" } }""" ) assert(svr.waitForString(10.seconds) { s => - s contains """"id":3""" + s.contains(""""id":3""") }) } } diff --git a/server-test/src/test/scala/testpkg/ResponseTest.scala b/server-test/src/test/scala/testpkg/ResponseTest.scala index fd791ae36..5db0dad94 100644 --- a/server-test/src/test/scala/testpkg/ResponseTest.scala +++ b/server-test/src/test/scala/testpkg/ResponseTest.scala @@ -18,8 +18,8 @@ class ResponseTest extends AbstractServerTest { assert(svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - (s contains """"id":"10"""") && - (s contains "scala-library-2.12.20.jar") + s.contains(""""id":"10"""") && + s.contains("scala-library-2.12.20.jar") }) } @@ -29,8 +29,8 @@ class ResponseTest extends AbstractServerTest { ) assert(svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - (s contains """"id":"11"""") && - (s contains "scala-library-2.12.20.jar") + s.contains(""""id":"11"""") && + s.contains("scala-library-2.12.20.jar") }) } @@ -40,7 +40,7 @@ class ResponseTest extends AbstractServerTest { ) assert(svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - (s contains """"error":{"code":-33000,"message":"fail message"""") + s.contains(""""error":{"code":-33000,"message":"fail message"""") }) } @@ -50,7 +50,7 @@ class ResponseTest extends AbstractServerTest { ) assert(svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - (s contains """"error":{"code":500,"message":"some error"""") + s.contains(""""error":{"code":500,"message":"some error"""") }) } @@ -60,7 +60,7 @@ class ResponseTest extends AbstractServerTest { ) assert(svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - (s contains """{"jsonrpc":"2.0","method":"foo/something","params":"something"}""") + s.contains("""{"jsonrpc":"2.0","method":"foo/something","params":"something"}""") }) } @@ -71,14 +71,14 @@ class ResponseTest extends AbstractServerTest { assert { svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - s contains "\"id\":\"15\"" + s.contains("\"id\":\"15\"") } } assert { // the second response should never be sent svr.neverReceive(500.milliseconds) { s => if (!s.contains("systemOut")) println(s) - s contains "\"id\":\"15\"" + s.contains("\"id\":\"15\"") } } } @@ -90,14 +90,14 @@ class ResponseTest extends AbstractServerTest { assert { svr.waitForString(10.seconds) { s => if (!s.contains("systemOut")) println(s) - s contains "\"id\":\"16\"" + s.contains("\"id\":\"16\"") } } assert { // the second response (result or error) should never be sent svr.neverReceive(500.milliseconds) { s => if (!s.contains("systemOut")) println(s) - s contains "\"id\":\"16\"" + s.contains("\"id\":\"16\"") } } } @@ -109,7 +109,7 @@ class ResponseTest extends AbstractServerTest { assert { svr.neverReceive(500.milliseconds) { s => if (!s.contains("systemOut")) println(s) - s contains "\"result\":\"notification result\"" + s.contains("\"result\":\"notification result\"") } } } diff --git a/server-test/src/test/scala/testpkg/ServerCompletionsTest.scala b/server-test/src/test/scala/testpkg/ServerCompletionsTest.scala index 8ba720b78..350a65c34 100644 --- a/server-test/src/test/scala/testpkg/ServerCompletionsTest.scala +++ b/server-test/src/test/scala/testpkg/ServerCompletionsTest.scala @@ -19,7 +19,7 @@ class ServerCompletionsTest extends AbstractServerTest { s"""{ "jsonrpc": "2.0", "id": 15, "method": "sbt/completion", "params": $completionStr }""" ) assert(svr.waitForString(10.seconds) { s => - s contains """"result":{"items":[""" + s.contains(""""result":{"items":[""") }) } @@ -29,7 +29,7 @@ class ServerCompletionsTest extends AbstractServerTest { s"""{ "jsonrpc": "2.0", "id": 16, "method": "sbt/completion", "params": $completionStr }""" ) assert(svr.waitForString(10.seconds) { s => - s contains """"result":{"items":["hello"]""" + s.contains(""""result":{"items":["hello"]""") }) } diff --git a/server-test/src/test/scala/testpkg/TestServer.scala b/server-test/src/test/scala/testpkg/TestServer.scala index 6d5ca48b7..4d1c8eb99 100644 --- a/server-test/src/test/scala/testpkg/TestServer.scala +++ b/server-test/src/test/scala/testpkg/TestServer.scala @@ -27,8 +27,8 @@ import org.scalatest.funsuite.AnyFunSuite import org.scalatest.BeforeAndAfterAll trait AbstractServerTest extends AnyFunSuite with BeforeAndAfterAll { - private var temp: File = _ - var svr: TestServer = _ + private var temp: File = scala.compiletime.uninitialized + var svr: TestServer = scala.compiletime.uninitialized def testDirectory: String def testPath: Path = temp.toPath.resolve(testDirectory) @@ -84,7 +84,7 @@ object TestServer { Try { testServer.waitForString(10.seconds) { s => println(s) - s contains """"capabilities":{"""" + s.contains(""""capabilities":{"""") } } init.get @@ -124,7 +124,7 @@ object TestServer { Try { testServer.waitForString(10.seconds) { s => if (s.nonEmpty) println(s) - s contains """"capabilities":{"""" + s.contains(""""capabilities":{"""") } } diff --git a/tasks-standard/src/main/scala/sbt/Task.scala b/tasks-standard/src/main/scala/sbt/Task.scala index 5995ce01a..099d4d10c 100644 --- a/tasks-standard/src/main/scala/sbt/Task.scala +++ b/tasks-standard/src/main/scala/sbt/Task.scala @@ -20,7 +20,7 @@ final case class Task[A](info: Info[A], work: Action[A]) extends TaskId[A]: override def toString = info.name getOrElse ("Task(" + info + ")") override def hashCode = info.hashCode - def tag(tags: Tag*): Task[A] = tagw(tags.map(t => (t, 1)): _*) + def tag(tags: Tag*): Task[A] = tagw(tags.map(t => (t, 1))*) def tagw(tags: (Tag, Int)*): Task[A] = { val tgs: TagMap = info.get(tagsKey).getOrElse(TagMap.empty) val value = tags.foldLeft(tgs)((acc, tag) => acc + tag) diff --git a/tasks-standard/src/main/scala/sbt/internal/Action.scala b/tasks-standard/src/main/scala/sbt/internal/Action.scala index 77baca4bb..cf823e16c 100644 --- a/tasks-standard/src/main/scala/sbt/internal/Action.scala +++ b/tasks-standard/src/main/scala/sbt/internal/Action.scala @@ -38,7 +38,7 @@ enum Action[A]: // FlatMapped[A, K](alist.transform(in, g), g.fn[A] compose f, alist) /** A computation `in` that requires other tasks `deps` to be evaluated first. */ - case DependsOn[A](in: Task[A], deps: Seq[Task[_]]) extends Action[A] + case DependsOn[A](in: Task[A], deps: Seq[Task[?]]) extends Action[A] // private[sbt] def mapTask(g: Task ~> Task) = DependsOn[A](g(in), deps.map(t => g(t))) /** diff --git a/tasks-standard/src/main/scala/sbt/std/TaskExtra.scala b/tasks-standard/src/main/scala/sbt/std/TaskExtra.scala index 89cf3a18a..946d46b3e 100644 --- a/tasks-standard/src/main/scala/sbt/std/TaskExtra.scala +++ b/tasks-standard/src/main/scala/sbt/std/TaskExtra.scala @@ -31,7 +31,7 @@ sealed trait SingleInTask[S] { def flatMap[T](f: S => Task[T]): Task[T] def mapN[T](f: S => T): Task[T] def map[T](f: S => T): Task[T] - def dependsOn(tasks: Task[_]*): Task[S] + def dependsOn(tasks: Task[?]*): Task[S] def andFinally(fin: => Unit): Task[S] def doFinally(t: Task[Unit]): Task[S] @@ -99,14 +99,14 @@ sealed trait ProcessPipe { } trait TaskExtra0 { - final implicit def joinAnyTasks(in: Seq[Task[_]]): JoinTask[Any, Seq] = + final implicit def joinAnyTasks(in: Seq[Task[?]]): JoinTask[Any, Seq] = joinTasks0[Any](existToAny(in)) private[sbt] def joinTasks0[S](in: Seq[Task[S]]): JoinTask[S, Seq] = new JoinTask[S, Seq] { def join: Task[Seq[S]] = Task[Seq[S]](Info(), Action.Join(in, (s: Seq[Result[S]]) => Right(TaskExtra.all(s)))) def reduced(f: (S, S) => S): Task[S] = TaskExtra.reduced(in.toIndexedSeq, f) } - private[sbt] def existToAny(in: Seq[Task[_]]): Seq[Task[Any]] = in.asInstanceOf[Seq[Task[Any]]] + private[sbt] def existToAny(in: Seq[Task[?]]): Seq[Task[Any]] = in.asInstanceOf[Seq[Task[Any]]] } trait TaskExtra extends TaskExtra0 { @@ -178,7 +178,7 @@ trait TaskExtra extends TaskExtra0 { Action.Mapped[A, Tuple1[S]](Tuple1(in), { case Tuple1(a) => f(a) }) ) - override def dependsOn(tasks: Task[_]*): Task[S] = Task(newInfo, Action.DependsOn(in, tasks)) + override def dependsOn(tasks: Task[?]*): Task[S] = Task(newInfo, Action.DependsOn(in, tasks)) override def flatMapN[T](f: S => Task[T]): Task[T] = flatMapR(f.compose(successM)) @@ -211,8 +211,8 @@ trait TaskExtra extends TaskExtra0 { } final implicit def pipeToProcess[Key]( - t: Task[_] - )(implicit streams: Task[TaskStreams[Key]], key: Task[_] => Key): ProcessPipe = + t: Task[?] + )(implicit streams: Task[TaskStreams[Key]], key: Task[?] => Key): ProcessPipe = new ProcessPipe { def #|(p: ProcessBuilder): Task[Int] = pipe0(None, p) def pipe(sid: String)(p: ProcessBuilder): Task[Int] = pipe0(Some(sid), p) @@ -227,8 +227,8 @@ trait TaskExtra extends TaskExtra0 { } final implicit def binaryPipeTask[Key]( - in: Task[_] - )(implicit streams: Task[TaskStreams[Key]], key: Task[_] => Key): BinaryPipe = + in: Task[?] + )(implicit streams: Task[TaskStreams[Key]], key: Task[?] => Key): BinaryPipe = new BinaryPipe { def binary[T](f: BufferedInputStream => T): Task[T] = pipe0(None, f) def binary[T](sid: String)(f: BufferedInputStream => T): Task[T] = pipe0(Some(sid), f) @@ -244,8 +244,8 @@ trait TaskExtra extends TaskExtra0 { private def toFile(f: File) = (in: InputStream) => IO.transfer(in, f) } final implicit def textPipeTask[Key]( - in: Task[_] - )(implicit streams: Task[TaskStreams[Key]], key: Task[_] => Key): TextPipe = new TextPipe { + in: Task[?] + )(implicit streams: Task[TaskStreams[Key]], key: Task[?] => Key): TextPipe = new TextPipe { def text[T](f: BufferedReader => T): Task[T] = pipe0(None, f) def text[T](sid: String)(f: BufferedReader => T): Task[T] = pipe0(Some(sid), f) @@ -255,8 +255,8 @@ trait TaskExtra extends TaskExtra0 { } } final implicit def linesTask[Key]( - in: Task[_] - )(implicit streams: Task[TaskStreams[Key]], key: Task[_] => Key): TaskLines = new TaskLines { + in: Task[?] + )(implicit streams: Task[TaskStreams[Key]], key: Task[?] => Key): TaskLines = new TaskLines { def lines: Task[List[String]] = lines0(None) def lines(sid: String): Task[List[String]] = lines0(Some(sid)) @@ -265,7 +265,7 @@ trait TaskExtra extends TaskExtra0 { IO.readLines(s.readText(key(in), sid)) } } - implicit def processToTask(p: ProcessBuilder)(implicit streams: Task[TaskStreams[_]]): Task[Int] = + implicit def processToTask(p: ProcessBuilder)(implicit streams: Task[TaskStreams[?]]): Task[Int] = streams map { s => val pio = TaskExtra.processIO(s) (p run pio).exitValue() @@ -273,7 +273,7 @@ trait TaskExtra extends TaskExtra0 { } object TaskExtra extends TaskExtra { - def processIO(s: TaskStreams[_]): ProcessIO = { + def processIO(s: TaskStreams[?]): ProcessIO = { def transfer(id: String) = (in: InputStream) => BasicIO.transferFully(in, s.binary(id)) new ProcessIO(_.close(), transfer(s.outID), transfer(s.errorID)) } @@ -331,6 +331,6 @@ object TaskExtra extends TaskExtra { // The "taskDefinitionKey" is used, at least, by the ".previous" functionality. // But apparently it *cannot* survive a task map/flatMap/etc. See actions/depends-on. - private[sbt] def newInfo[A](info: Info[_]): Info[A] = + private[sbt] def newInfo[A](info: Info[?]): Info[A] = Info[A](AttributeMap(info.attributes.entries.filter(_.key.label != "taskDefinitionKey"))) } diff --git a/tasks-standard/src/main/scala/sbt/std/Transform.scala b/tasks-standard/src/main/scala/sbt/std/Transform.scala index c29abcd90..134344c9c 100644 --- a/tasks-standard/src/main/scala/sbt/std/Transform.scala +++ b/tasks-standard/src/main/scala/sbt/std/Transform.scala @@ -21,7 +21,7 @@ object Transform: def fromDummyStrict[T](original: Task[T], value: T): Task[T] = fromDummy(original)(value) - final case class DummyTaskMap(mappings: List[TaskAndValue[_]]) { + final case class DummyTaskMap(mappings: List[TaskAndValue[?]]) { def ::[T](tav: (Task[T], T)): DummyTaskMap = DummyTaskMap(new TaskAndValue(tav._1, tav._2) :: mappings) } diff --git a/tasks-standard/src/test/scala/Execute.scala b/tasks-standard/src/test/scala/Execute.scala index b75eaf66a..12ef94963 100644 --- a/tasks-standard/src/test/scala/Execute.scala +++ b/tasks-standard/src/test/scala/Execute.scala @@ -37,7 +37,7 @@ object ExecuteSpec extends Properties("Execute") { property("evaluates chained mapped task") = forAllNoShrink(iGen, MaxTasksGen, MaxWorkersGen) { (i: Int, times: Int, workers: Int) => ("Workers: " + workers) |: ("Value: " + i) |: ("Times: " + times) |: { - val initial = task(0) map (identity[Int]) + val initial = task(0).map(identity[Int]) def t = (0 until times).foldLeft(initial)((t, ignore) => t.map(_ + i)) checkResult(tryRun(t, false, workers), i * times) } diff --git a/tasks-standard/src/test/scala/TaskRunnerCircular.scala b/tasks-standard/src/test/scala/TaskRunnerCircular.scala index bc2c8576f..cb84036a3 100644 --- a/tasks-standard/src/test/scala/TaskRunnerCircular.scala +++ b/tasks-standard/src/test/scala/TaskRunnerCircular.scala @@ -14,10 +14,10 @@ import TaskGen._ object TaskRunnerCircularTest extends Properties("TaskRunner Circular") { property("Catches circular references") = forAll(MaxTasksGen, MaxWorkersGen) { - checkCircularReferences _ + checkCircularReferences } property("Allows references to completed tasks") = forAllNoShrink(MaxTasksGen, MaxWorkersGen) { - allowedReference _ + allowedReference } final def allowedReference(intermediate: Int, workers: Int) = { val top = task(intermediate).named("top") diff --git a/tasks-standard/src/test/scala/Test.scala b/tasks-standard/src/test/scala/Test.scala index 5a2a70c89..e5f9ceb12 100644 --- a/tasks-standard/src/test/scala/Test.scala +++ b/tasks-standard/src/test/scala/Test.scala @@ -32,17 +32,17 @@ object Test extends std.TaskExtra: } // workaround for double definition bug throw Incomplete(None, causes = cs) } - val d2 = t3(a, b2, c) mapR f + val d2 = t3(a, b2, c).mapR(f) val f2: Values => Task[Any] = { case (Result.Value(aa), Result.Value(bb), Result.Value(cc)) => task(s"$aa $bb $cc") case _ => d3 } - lazy val d = t3(a, b, c) flatMapR f2 + lazy val d = t3(a, b, c).flatMapR(f2) val f3: Values => Task[Any] = { case (Result.Value(aa), Result.Value(bb), Result.Value(cc)) => task(s"$aa $bb $cc") case _ => d2 } - lazy val d3 = t3(a, b, c) flatMapR f3 + lazy val d3 = t3(a, b, c).flatMapR(f3) def d4(i: Int): Task[Int] = nop flatMap { _ => val x = math.random; if (x < 0.01) task(i); else d4(i + 1) diff --git a/tasks-standard/src/test/scala/TestRunnerCall.scala b/tasks-standard/src/test/scala/TestRunnerCall.scala index 849ea0d4f..019acf217 100644 --- a/tasks-standard/src/test/scala/TestRunnerCall.scala +++ b/tasks-standard/src/test/scala/TestRunnerCall.scala @@ -31,7 +31,7 @@ object TaskRunnerCallTest extends Properties("TaskRunner Call") { else iterate((index + 1, x2, x1 + x2)) } - def iterate(iteration: (Int, Int, Int)) = task(iteration) flatMap next.tupled + def iterate(iteration: (Int, Int, Int)) = task(iteration).flatMap(next.tupled) iterate((1, 0, 1)) } final def fibDirect(i: Int): Int = { diff --git a/tasks/src/main/scala/sbt/ConcurrentRestrictions.scala b/tasks/src/main/scala/sbt/ConcurrentRestrictions.scala index 3d8b19bc7..f4847b18f 100644 --- a/tasks/src/main/scala/sbt/ConcurrentRestrictions.scala +++ b/tasks/src/main/scala/sbt/ConcurrentRestrictions.scala @@ -199,7 +199,7 @@ object ConcurrentRestrictions { backing: Executor, tags: ConcurrentRestrictions, warn: String => Unit - ): CompletionService with AutoCloseable = { + ): CompletionService & AutoCloseable = { completionService(backing, tags, warn, _ => false) } @@ -213,7 +213,7 @@ object ConcurrentRestrictions { tags: ConcurrentRestrictions, warn: String => Unit, isSentinel: TaskId[?] => Boolean, - ): CompletionService with CancelSentiels with AutoCloseable = { + ): CompletionService & CancelSentiels & AutoCloseable = { // Represents submitted work for a task. final class Enqueue(val node: TaskId[?], val work: () => Completed) @@ -241,7 +241,7 @@ object ConcurrentRestrictions { */ private val pending = new LinkedList[Enqueue] - private val sentinels: mutable.ListBuffer[JFuture[_]] = mutable.ListBuffer.empty + private val sentinels: mutable.ListBuffer[JFuture[?]] = mutable.ListBuffer.empty def cancelSentinels(): Unit = { sentinels.toList foreach { s => @@ -251,24 +251,22 @@ object ConcurrentRestrictions { } def submit(node: TaskId[?], work: () => Completed): Unit = synchronized { - if (closed.get) throw new RejectedExecutionException - else if (isSentinel(node)) { + if closed.get then throw new RejectedExecutionException + else if isSentinel(node) then // skip all checks for sentinels sentinels += CompletionService.submitFuture(work, jservice) - } else { + else val newState = tags.add(tagState, node) // if the new task is allowed to run concurrently with the currently running tasks, // submit it to be run by the backing j.u.c.CompletionService - if (tags valid newState) { + if tags.valid(newState) then tagState = newState submitValid(node, work) () - } else { - if (running == 0) errorAddingToIdle() + else + if running == 0 then errorAddingToIdle() pending.add(new Enqueue(node, work)) () - } - } () } private def submitValid(node: TaskId[?], work: () => Completed): Unit = { diff --git a/tasks/src/main/scala/sbt/Execute.scala b/tasks/src/main/scala/sbt/Execute.scala index 2ecafb563..e2fa4a579 100644 --- a/tasks/src/main/scala/sbt/Execute.scala +++ b/tasks/src/main/scala/sbt/Execute.scala @@ -96,7 +96,7 @@ private[sbt] final class Execute( addNew(root) processAll() - assert(results contains root, "No result for root node.") + assert(results.contains(root), "No result for root node.") val finalResults = triggers.onComplete(results) progress.afterAllCompleted(finalResults) progress.stop() @@ -155,7 +155,7 @@ private[sbt] final class Execute( if (done(target)) assert(done(node)) else { assert(calling(node)) - assert(callers(target) contains node) + assert(callers(target).contains(node)) } readyInv(node) } @@ -391,11 +391,11 @@ private[sbt] final class Execute( def cycleCheck(node: TaskId[?], target: TaskId[?]): Unit = { if (node eq target) cyclic(node, target, "Cannot call self") val all = IDSet.create[TaskId[?]] - def allCallers(n: TaskId[?]): Unit = (all process n)(()) { + def allCallers(n: TaskId[?]): Unit = all.process(n)(()) { callers.get(n).toList.flatten.foreach(allCallers) } allCallers(node) - if (all contains target) cyclic(node, target, "Cyclic reference") + if all.contains(target) then cyclic(node, target, "Cyclic reference") } def cyclic(caller: TaskId[?], target: TaskId[?], msg: String) = throw new Incomplete( diff --git a/testing/src/main/scala/sbt/TestFramework.scala b/testing/src/main/scala/sbt/TestFramework.scala index 071c05f81..a32930748 100644 --- a/testing/src/main/scala/sbt/TestFramework.scala +++ b/testing/src/main/scala/sbt/TestFramework.scala @@ -181,7 +181,7 @@ private[sbt] final class TestRunner( } object TestFramework { - def apply(implClassNames: String*): TestFramework = new TestFramework(implClassNames: _*) + def apply(implClassNames: String*): TestFramework = new TestFramework(implClassNames*) def getFingerprints(framework: Framework): Seq[Fingerprint] = framework.getClass.getMethod("fingerprints").invoke(framework) match { @@ -290,7 +290,7 @@ object TestFramework { val taskDef = testTask.taskDef (taskDef.fullyQualifiedName, createTestFunction(loader, taskDef, runner, testTask)) } - }: _*) + }*) val endTask = (result: TestResult) => foreachListenerSafe(_.doComplete(result)) (startTask, order(testTasks, ordered), endTask) diff --git a/util-cache/src/main/scala/sbt/util/ActionCacheStore.scala b/util-cache/src/main/scala/sbt/util/ActionCacheStore.scala index c292ce9c4..0149802b4 100644 --- a/util-cache/src/main/scala/sbt/util/ActionCacheStore.scala +++ b/util-cache/src/main/scala/sbt/util/ActionCacheStore.scala @@ -319,7 +319,7 @@ class DiskActionCacheStore(base: Path, converter: FileConverter) extends Abstrac FileTreeView.default .list(dirPath.toGlob / ** / "*") .filter(!_._2.isDirectory) - .map(_._1): _* + .map(_._1)* ) def doSync(ref: HashedVirtualFileRef, in: Path): Unit = val d = Digest(ref) diff --git a/util-cache/src/main/scala/sbt/util/BasicCacheImplicits.scala b/util-cache/src/main/scala/sbt/util/BasicCacheImplicits.scala index 44ccc710e..c3101507d 100644 --- a/util-cache/src/main/scala/sbt/util/BasicCacheImplicits.scala +++ b/util-cache/src/main/scala/sbt/util/BasicCacheImplicits.scala @@ -24,7 +24,7 @@ trait BasicCacheImplicits extends HashedVirtualFileRefFormats { self: BasicJsonP } def singleton[T](t: T): SingletonCache[T] = - SingletonCache.basicSingletonCache(asSingleton(t)) + SingletonCache.basicSingletonCache(using asSingleton(t)) implicit lazy val virtualFileRefIsoString: IsoString[VirtualFileRef] = IsoString.iso(_.id, VirtualFileRef.of) diff --git a/util-collection/src/main/scala/sbt/internal/util/Attributes.scala b/util-collection/src/main/scala/sbt/internal/util/Attributes.scala index 8d72a2b29..f0f1412f5 100644 --- a/util-collection/src/main/scala/sbt/internal/util/Attributes.scala +++ b/util-collection/src/main/scala/sbt/internal/util/Attributes.scala @@ -52,7 +52,7 @@ sealed trait AttributeKey[A]: * will delegate to the values associated with these keys. The delegation proceeds in order the * keys are returned here. */ - def extend: Seq[AttributeKey[_]] + def extend: Seq[AttributeKey[?]] /** * Specifies whether this key is a local, anonymous key (`true`) or not (`false`). This is @@ -104,14 +104,14 @@ object AttributeKey { def apply[A: KeyTag: OptJsonWriter]( name: String, description: String, - extend: Seq[AttributeKey[_]] + extend: Seq[AttributeKey[?]] ): AttributeKey[A] = apply(name, description, extend, Int.MaxValue) def apply[A: KeyTag: OptJsonWriter]( name: String, description: String, - extend: Seq[AttributeKey[_]], + extend: Seq[AttributeKey[?]], rank: Int ): AttributeKey[A] = make(name, Some(description), extend, rank) @@ -122,7 +122,7 @@ object AttributeKey { private def make[A: KeyTag: OptJsonWriter]( name: String, description0: Option[String], - extend0: Seq[AttributeKey[_]], + extend0: Seq[AttributeKey[?]], rank0: Int ): AttributeKey[A] = new SharedAttributeKey[A]: @@ -134,7 +134,7 @@ object AttributeKey { override def tag: KeyTag[A] = summon override val label: String = Util.hyphenToCamel(name) override def description: Option[String] = description0 - override def extend: Seq[AttributeKey[_]] = extend0 + override def extend: Seq[AttributeKey[?]] = extend0 override def rank: Int = rank0 override def optJsonWriter: OptJsonWriter[A] = summon @@ -143,7 +143,7 @@ object AttributeKey { override def tag: KeyTag[A] = summon override def label: String = LocalLabel override def description: Option[String] = None - override def extend: Seq[AttributeKey[_]] = Nil + override def extend: Seq[AttributeKey[?]] = Nil override def toString = label override def isLocal: Boolean = true override def rank: Int = Int.MaxValue @@ -194,13 +194,13 @@ trait AttributeMap { * All keys with defined mappings. There may be multiple keys with the same `label`, but different * types. */ - def keys: Iterable[AttributeKey[_]] + def keys: Iterable[AttributeKey[?]] /** * Adds the mappings in `o` to this map, with mappings in `o` taking precedence over existing * mappings. */ - def ++(o: Iterable[AttributeEntry[_]]): AttributeMap + def ++(o: Iterable[AttributeEntry[?]]): AttributeMap /** * Combines the mappings in `o` with the mappings in this map, with mappings in `o` taking @@ -212,7 +212,7 @@ trait AttributeMap { * All mappings in this map. The [[AttributeEntry]] type preserves the typesafety of mappings, * although the specific types are unknown. */ - def entries: Iterable[AttributeEntry[_]] + def entries: Iterable[AttributeEntry[?]] /** `true` if there are no mappings in this map, `false` if there are. */ def isEmpty: Boolean @@ -230,16 +230,16 @@ object AttributeMap { val empty: AttributeMap = new BasicAttributeMap(Map.empty) /** Constructs an [[AttributeMap]] containing the given `entries`. */ - def apply(entries: Iterable[AttributeEntry[_]]): AttributeMap = empty ++ entries + def apply(entries: Iterable[AttributeEntry[?]]): AttributeMap = empty ++ entries /** Constructs an [[AttributeMap]] containing the given `entries`. */ - def apply(entries: AttributeEntry[_]*): AttributeMap = empty ++ entries + def apply(entries: AttributeEntry[?]*): AttributeMap = empty ++ entries /** Presents an `AttributeMap` as a natural transformation. */ // implicit def toNatTrans(map: AttributeMap): AttributeKey ~> Id = λ[AttributeKey ~> Id](map(_)) } -private class BasicAttributeMap(private val backing: Map[AttributeKey[_], Any]) +private class BasicAttributeMap(private val backing: Map[AttributeKey[?], Any]) extends AttributeMap { def isEmpty: Boolean = backing.isEmpty @@ -251,18 +251,18 @@ private class BasicAttributeMap(private val backing: Map[AttributeKey[_], Any]) def put[T](k: AttributeKey[T], value: T): AttributeMap = new BasicAttributeMap(backing.updated(k, value: Any)) - def keys: Iterable[AttributeKey[_]] = backing.keys + def keys: Iterable[AttributeKey[?]] = backing.keys - def ++(o: Iterable[AttributeEntry[_]]): AttributeMap = + def ++(o: Iterable[AttributeEntry[?]]): AttributeMap = new BasicAttributeMap(o.foldLeft(backing)((b, e) => b.updated(e.key, e.value: Any))) def ++(o: AttributeMap): AttributeMap = o match { case bam: BasicAttributeMap => - new BasicAttributeMap(Map(backing.toSeq ++ bam.backing.toSeq: _*)) + new BasicAttributeMap(Map(backing.toSeq ++ bam.backing.toSeq*)) case _ => o ++ this } - def entries: Iterable[AttributeEntry[_]] = + def entries: Iterable[AttributeEntry[?]] = backing.collect { case (k: AttributeKey[kt], v) => AttributeEntry(k, v.asInstanceOf[kt]) } @@ -317,7 +317,7 @@ object Attributed: (entry._1.toString, entry._2), (entries: Seq[(String, String)]) => Map((entries.map: entry => - (StringAttributeKey(entry._1), entry._2)): _*), + (StringAttributeKey(entry._1), entry._2))*), ) given [A1: ClassTag: JsonFormat] diff --git a/util-collection/src/main/scala/sbt/internal/util/INode.scala b/util-collection/src/main/scala/sbt/internal/util/INode.scala index 3ae954a43..e15c38589 100644 --- a/util-collection/src/main/scala/sbt/internal/util/INode.scala +++ b/util-collection/src/main/scala/sbt/internal/util/INode.scala @@ -25,7 +25,7 @@ abstract class EvaluateSettings[ScopeType]: import init._ protected def executor: Executor - protected def compiledSettings: Seq[Compiled[_]] + protected def compiledSettings: Seq[Compiled[?]] import EvaluationState.* @@ -54,12 +54,12 @@ abstract class EvaluateSettings[ScopeType]: case Some(i) => single[s, A](transform(i), x => o.f(Some(x))) case StaticScopes => strictConstant(allScopes) - private lazy val roots: Seq[INode[_]] = compiledSettings.flatMap { cs => + private lazy val roots: Seq[INode[?]] = compiledSettings.flatMap { cs => (cs.settings map { s => val t = transform(s.init) static(s.key) = t t - }): Seq[INode[_]] + }): Seq[INode[?]] } private val running = new AtomicInteger @@ -85,9 +85,9 @@ abstract class EvaluateSettings[ScopeType]: private lazy val getValue: [A] => INode[A] => A = [A] => (fa: INode[A]) => fa.get - private def submitEvaluate(node: INode[_]) = submit(node.evaluate()) + private def submitEvaluate(node: INode[?]) = submit(node.evaluate()) - private def submitCallComplete[A](node: BindNode[_, A], value: A) = + private def submitCallComplete[A](node: BindNode[?, A], value: A) = submit(node.callComplete(value)) private def submit(work: => Unit): Unit = @@ -107,10 +107,10 @@ abstract class EvaluateSettings[ScopeType]: private sealed abstract class INode[A1]: private var state: EvaluationState = New - private var value: A1 = _ - private val blocking = new collection.mutable.ListBuffer[INode[_]] + private var value: A1 = scala.compiletime.uninitialized + private val blocking = new collection.mutable.ListBuffer[INode[?]] private var blockedOn: Int = 0 - private val calledBy = new collection.mutable.ListBuffer[BindNode[_, A1]] + private val calledBy = new collection.mutable.ListBuffer[BindNode[?, A1]] override def toString(): String = getClass.getName + " (state=" + state + ",blockedOn=" + blockedOn + ",calledBy=" + calledBy.size + ",blocking=" + blocking.size + "): " + @@ -129,7 +129,7 @@ abstract class EvaluateSettings[ScopeType]: value } - final def doneOrBlock(from: INode[_]): Boolean = synchronized { + final def doneOrBlock(from: INode[?]): Boolean = synchronized { val ready = state == Evaluated if (!ready) { blocking += from @@ -167,7 +167,7 @@ abstract class EvaluateSettings[ScopeType]: final def evaluate(): Unit = synchronized { evaluate0() } - protected final def makeCall(source: BindNode[_, A1], target: INode[A1]): Unit = { + protected final def makeCall(source: BindNode[?, A1], target: INode[A1]): Unit = { assert(state == Ready, "Invalid state for call to makeCall: " + toString) state = Calling target.call(source) @@ -189,7 +189,7 @@ abstract class EvaluateSettings[ScopeType]: calledBy.clear() } - final def call(by: BindNode[_, A1]): Unit = synchronized { + final def call(by: BindNode[?, A1]): Unit = synchronized { registerIfNew() state match { case Evaluated => submitCallComplete(by, value) @@ -199,7 +199,7 @@ abstract class EvaluateSettings[ScopeType]: } } - protected def dependsOn: Seq[INode[_]] + protected def dependsOn: Seq[INode[?]] protected def evaluate0(): Unit end INode @@ -212,7 +212,7 @@ abstract class EvaluateSettings[ScopeType]: MixedNode[Tuple1[A1], A2](Tuple1(in), { case Tuple1(a) => f(a) }) private final class BindNode[A1, A2](in: INode[A1], f: A1 => INode[A2]) extends INode[A2]: - protected def dependsOn: Seq[INode[_]] = in :: Nil + protected def dependsOn: Seq[INode[?]] = in :: Nil protected def evaluate0(): Unit = makeCall(this, f(in.get)) def callComplete(value: A2): Unit = synchronized { assert(isCalling, "Invalid state for callComplete(" + value + "): " + toString) @@ -223,11 +223,11 @@ abstract class EvaluateSettings[ScopeType]: private final class MixedNode[Tup <: Tuple, A1](in: Tuple.Map[Tup, INode], f: Tup => A1) extends INode[A1]: import TupleMapExtension.* - protected override def dependsOn: Seq[INode[_]] = in.toList0 + protected override def dependsOn: Seq[INode[?]] = in.toList0 protected override def evaluate0(): Unit = setValue(f(in.unmap(getValue))) private final class UniformNode[A1, A2](in: List[INode[A1]], f: List[A1] => A2) extends INode[A2]: - protected override def dependsOn: Seq[INode[_]] = in + protected override def dependsOn: Seq[INode[?]] = in protected override def evaluate0(): Unit = setValue(f(in.map(_.get))) end EvaluateSettings diff --git a/util-collection/src/main/scala/sbt/internal/util/PMap.scala b/util-collection/src/main/scala/sbt/internal/util/PMap.scala index f74131d07..b129902ea 100644 --- a/util-collection/src/main/scala/sbt/internal/util/PMap.scala +++ b/util-collection/src/main/scala/sbt/internal/util/PMap.scala @@ -15,7 +15,7 @@ trait RMap[K[_], V[_]] { def contains[T](k: K[T]): Boolean def toSeq: Seq[(K[Any], V[Any])] - def toTypedSeq: Seq[TPair[_]] = toSeq.map { case (k: K[t], v) => + def toTypedSeq: Seq[TPair[?]] = toSeq.map { case (k: K[t], v) => TPair[t](k, v.asInstanceOf[V[t]]) } @@ -72,12 +72,12 @@ object IMap { def remove[T](k: K[T]) = new IMap0[K, V](backing - k.asInstanceOf) def mapValue[T](k: K[T], init: V[T], f: V[T] => V[T]) = - put(k, f(this get k getOrElse init)) + put(k, f(this.get(k).getOrElse(init))) def mapValues[V2[_]](f: [A] => V[A] => V2[A]) = new IMap0[K, V2](Map(backing.iterator.map { case (k, v) => k -> f(v.asInstanceOf[V[Any]]) - }.toArray: _*)) + }.toArray*)) def toSeq = backing.toSeq.asInstanceOf[Seq[(K[Any], V[Any])]] def keys = backing.keys.asInstanceOf[Iterable[K[Any]]] @@ -107,7 +107,7 @@ class DelegatingPMap[K[_], V[_]](backing: mutable.Map[K[Any], V[Any]]) cast[T](backing.getOrElseUpdate(k.asInstanceOf, make.asInstanceOf)) def mapValue[T](k: K[T], init: V[T], f: V[T] => V[T]): V[T] = { - val v = f(this get k getOrElse init) + val v = f(this.get(k).getOrElse(init)) update(k, v) v } diff --git a/util-collection/src/main/scala/sbt/internal/util/Settings.scala b/util-collection/src/main/scala/sbt/internal/util/Settings.scala index e9e6f281c..33b4561a2 100644 --- a/util-collection/src/main/scala/sbt/internal/util/Settings.scala +++ b/util-collection/src/main/scala/sbt/internal/util/Settings.scala @@ -14,10 +14,10 @@ import scala.jdk.CollectionConverters.* sealed trait Settings[ScopeType]: def data: Map[ScopeType, AttributeMap] - def keys(scope: ScopeType): Set[AttributeKey[_]] + def keys(scope: ScopeType): Set[AttributeKey[?]] def scopes: Set[ScopeType] - def definingScope(scope: ScopeType, key: AttributeKey[_]): Option[ScopeType] - def allKeys[A](f: (ScopeType, AttributeKey[_]) => A): Seq[A] + def definingScope(scope: ScopeType, key: AttributeKey[?]): Option[ScopeType] + def allKeys[A](f: (ScopeType, AttributeKey[?]) => A): Seq[A] def get[A](scope: ScopeType, key: AttributeKey[A]): Option[A] def getDirect[A](scope: ScopeType, key: AttributeKey[A]): Option[A] def set[A](scope: ScopeType, key: AttributeKey[A], value: A): Settings[ScopeType] @@ -31,7 +31,7 @@ private final class Settings0[ScopeType]( def scopes: Set[ScopeType] = data.keySet def keys(scope: ScopeType) = data(scope).keys.toSet - def allKeys[A](f: (ScopeType, AttributeKey[_]) => A): Seq[A] = + def allKeys[A](f: (ScopeType, AttributeKey[?]) => A): Seq[A] = data.flatMap { case (scope, map) => map.keys.map(k => f(scope, k)) }.toSeq @@ -41,7 +41,7 @@ private final class Settings0[ScopeType]( getDirect(sc, key) }.headOption - def definingScope(scope: ScopeType, key: AttributeKey[_]): Option[ScopeType] = + def definingScope(scope: ScopeType, key: AttributeKey[?]): Option[ScopeType] = delegates(scope).find { sc => getDirect(sc, key).isDefined } @@ -64,7 +64,7 @@ trait Init[ScopeType]: * The Show instance used when a detailed String needs to be generated. * It is typically used when no context is available. */ - def showFullKey: Show[ScopedKey[_]] + def showFullKey: Show[ScopedKey[?]] sealed case class ScopedKey[A](scope: ScopeType, key: AttributeKey[A]) extends KeyedInitialize[A]: def scopedKey = this @@ -72,12 +72,12 @@ trait Init[ScopeType]: type SettingSeq[A] = Seq[Setting[A]] type ScopedMap = IMap[ScopedKey, SettingSeq] - type CompiledMap = Map[ScopedKey[_], Compiled[_]] + type CompiledMap = Map[ScopedKey[?], Compiled[?]] type MapScoped = [a] => ScopedKey[a] => ScopedKey[a] type ValidatedRef[A] = Either[Undefined, ScopedKey[A]] type ValidatedInit[A] = Either[Seq[Undefined], Initialize[A]] type ValidateRef = [a] => ScopedKey[a] => ValidatedRef[a] - type ScopeLocal = ScopedKey[_] => Seq[Setting[_]] + type ScopeLocal = ScopedKey[?] => Seq[Setting[?]] type MapConstant = [a] => ScopedKey[a] => Option[a] private[sbt] abstract class ValidateKeyRef { @@ -141,7 +141,7 @@ trait Init[ScopeType]: s: Setting[A1], allowDynamic: Boolean = false, filter: ScopeType => Boolean = const(true), - trigger: AttributeKey[_] => Boolean = const(true), + trigger: AttributeKey[?] => Boolean = const(true), default: Boolean = false ): Setting[A1] = deriveAllowed(s, allowDynamic) foreach sys.error @@ -157,7 +157,7 @@ trait Init[ScopeType]: // id is used for equality private[sbt] final def defaultSetting[T](s: Setting[T]): Setting[T] = s.default() - private[sbt] def defaultSettings(ss: Seq[Setting[_]]): Seq[Setting[_]] = + private[sbt] def defaultSettings(ss: Seq[Setting[?]]): Seq[Setting[?]] = ss.map(s => defaultSetting(s)) private final val nextID = new java.util.concurrent.atomic.AtomicLong @@ -177,9 +177,9 @@ trait Init[ScopeType]: def mapScope(f: ScopeType => ScopeType): MapScoped = [a] => (k: ScopedKey[a]) => k.copy(scope = f(k.scope)) - private def applyDefaults(ss: Seq[Setting[_]]): Seq[Setting[_]] = { - val result = new java.util.LinkedHashSet[Setting[_]] - val others = new java.util.ArrayList[Setting[_]] + private def applyDefaults(ss: Seq[Setting[?]]): Seq[Setting[?]] = { + val result = new java.util.LinkedHashSet[Setting[?]] + val others = new java.util.ArrayList[Setting[?]] ss.foreach { case u: DefaultSetting[_] => result.add(u) case r => others.add(r) @@ -188,10 +188,10 @@ trait Init[ScopeType]: result.asScala.toVector } - def compiled(init: Seq[Setting[_]], actual: Boolean = true)(using + def compiled(init: Seq[Setting[?]], actual: Boolean = true)(using delegates: ScopeType => Seq[ScopeType], scopeLocal: ScopeLocal, - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): CompiledMap = { val initDefaults = applyDefaults(init) // inject derived settings into scopes where their dependencies are directly defined @@ -207,20 +207,20 @@ trait Init[ScopeType]: } @deprecated("Use makeWithCompiledMap", "1.4.0") - def make(init: Seq[Setting[_]])(using + def make(init: Seq[Setting[?]])(using delegates: ScopeType => Seq[ScopeType], scopeLocal: ScopeLocal, - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): Settings[ScopeType] = makeWithCompiledMap(init)._2 - def makeWithCompiledMap(init: Seq[Setting[_]])(using + def makeWithCompiledMap(init: Seq[Setting[?]])(using delegates: ScopeType => Seq[ScopeType], scopeLocal: ScopeLocal, - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): (CompiledMap, Settings[ScopeType]) = val cMap = compiled(init)(using delegates, scopeLocal, display) // order the initializations. cyclic references are detected here. - val ordered: Seq[Compiled[_]] = sort(cMap) + val ordered: Seq[Compiled[?]] = sort(cMap) // evaluation: apply the initializations. try { (cMap, applyInits(ordered)) @@ -229,7 +229,7 @@ trait Init[ScopeType]: throw Uninitialized(cMap.keys.toSeq, delegates, rru.undefined, true) } - def sort(cMap: CompiledMap): Seq[Compiled[_]] = + def sort(cMap: CompiledMap): Seq[Compiled[?]] = Dag.topologicalSort(cMap.values)(_.dependencies.map(cMap)) def compile(sMap: ScopedMap): CompiledMap = @@ -251,8 +251,8 @@ trait Init[ScopeType]: (k, Compiled(k, deps, ss)) }.toMap - def grouped(init: Seq[Setting[_]]): ScopedMap = - val result = new java.util.HashMap[ScopedKey[_], Seq[Setting[_]]] + def grouped(init: Seq[Setting[?]]): ScopedMap = + val result = new java.util.HashMap[ScopedKey[?], Seq[Setting[?]]] init.foreach { s => result.putIfAbsent(s.key, Vector(s)) match { case null => @@ -270,25 +270,25 @@ trait Init[ScopeType]: if s.definitive then Vector(s) else ss :+ s - def addLocal(init: Seq[Setting[_]])(implicit scopeLocal: ScopeLocal): Seq[Setting[_]] = + def addLocal(init: Seq[Setting[?]])(implicit scopeLocal: ScopeLocal): Seq[Setting[?]] = Par(init).map(_.dependencies flatMap scopeLocal).toVector.flatten ++ init def delegate(sMap: ScopedMap)(implicit delegates: ScopeType => Seq[ScopeType], - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): ScopedMap = { - def refMap(ref: Setting[_], isFirst: Boolean) = new ValidateKeyRef { + def refMap(ref: Setting[?], isFirst: Boolean) = new ValidateKeyRef { def apply[T](k: ScopedKey[T], selfRefOk: Boolean) = delegateForKey(sMap, k, delegates(k.scope), ref, selfRefOk || !isFirst) } val undefined = new java.util.ArrayList[Undefined] - val result = new java.util.concurrent.ConcurrentHashMap[ScopedKey[_], Any] + val result = new java.util.concurrent.ConcurrentHashMap[ScopedKey[?], Any] val backing = sMap.toSeq Par(backing).foreach { case (key, settings) => - val valid = new java.util.ArrayList[Setting[_]] + val valid = new java.util.ArrayList[Setting[?]] val undefs = new java.util.ArrayList[Undefined] - def validate(s: Setting[_], first: Boolean): Unit = { + def validate(s: Setting[?], first: Boolean): Unit = { s.validateKeyReferenced(refMap(s, first)) match { case Right(v) => valid.add(v); () case Left(us) => us.foreach(u => undefs.add(u)) @@ -315,14 +315,14 @@ trait Init[ScopeType]: sMap: ScopedMap, k: ScopedKey[A1], scopes: Seq[ScopeType], - ref: Setting[_], + ref: Setting[?], selfRefOk: Boolean ): Either[Undefined, ScopedKey[A1]] = val skeys = scopes.iterator.map(x => ScopedKey(x, k.key)) - val definedAt = skeys.find(sk => (selfRefOk || ref.key != sk) && (sMap contains sk)) + val definedAt = skeys.find(sk => (selfRefOk || ref.key != sk) && (sMap.contains(sk))) definedAt.toRight(Undefined(ref, k)) - private def applyInits(ordered: Seq[Compiled[_]])(implicit + private def applyInits(ordered: Seq[Compiled[?]])(implicit delegates: ScopeType => Seq[ScopeType] ): Settings[ScopeType] = val x = @@ -340,10 +340,10 @@ trait Init[ScopeType]: def showUndefined( u: Undefined, - validKeys: Seq[ScopedKey[_]], + validKeys: Seq[ScopedKey[?]], delegates: ScopeType => Seq[ScopeType] )(implicit - display: Show[ScopedKey[_]] + display: Show[ScopedKey[?]] ): String = val guessed = guessIntendedScope(validKeys, delegates, u.referencedKey) val derived = u.defining.isDerived @@ -360,14 +360,14 @@ trait Init[ScopeType]: u.referencedKey ) + " from " + refString + sourceString + derivedString + guessedString - private def parenPosString(s: Setting[_]): String = + private def parenPosString(s: Setting[?]): String = s.positionString match { case None => ""; case Some(s) => " (" + s + ")" } def guessIntendedScope( - validKeys: Seq[ScopedKey[_]], + validKeys: Seq[ScopedKey[?]], delegates: ScopeType => Seq[ScopeType], - key: ScopedKey[_] - ): Option[ScopedKey[_]] = + key: ScopedKey[?] + ): Option[ScopedKey[?]] = val distances = validKeys.flatMap { validKey => refinedDistance(delegates, validKey, key).map(dist => (dist, validKey)) } @@ -375,8 +375,8 @@ trait Init[ScopeType]: def refinedDistance( delegates: ScopeType => Seq[ScopeType], - a: ScopedKey[_], - b: ScopedKey[_] + a: ScopedKey[?], + b: ScopedKey[?] ): Option[Int] = if a.key != b.key || a == b then None else { @@ -389,11 +389,11 @@ trait Init[ScopeType]: extends Exception(toString) def Uninitialized( - validKeys: Seq[ScopedKey[_]], + validKeys: Seq[ScopedKey[?]], delegates: ScopeType => Seq[ScopeType], keys: Seq[Undefined], runtime: Boolean - )(implicit display: Show[ScopedKey[_]]): Uninitialized = { + )(implicit display: Show[ScopedKey[?]]): Uninitialized = { assert(keys.nonEmpty) val suffix = if (keys.length > 1) "s" else "" val prefix = if (runtime) "Runtime reference" else "Reference" @@ -407,49 +407,49 @@ trait Init[ScopeType]: final class Compiled[A1]( val key: ScopedKey[A1], - val dependencies: Iterable[ScopedKey[_]], + val dependencies: Iterable[ScopedKey[?]], val settings: Seq[Setting[A1]] ): override def toString = showFullKey.show(key) end Compiled - final class Flattened(val key: ScopedKey[_], val dependencies: Iterable[ScopedKey[_]]) + final class Flattened(val key: ScopedKey[?], val dependencies: Iterable[ScopedKey[?]]) - def flattenLocals(compiled: CompiledMap): Map[ScopedKey[_], Flattened] = { + def flattenLocals(compiled: CompiledMap): Map[ScopedKey[?], Flattened] = { val locals = compiled flatMap { case (key, comp) => if (key.key.isLocal) Seq(comp) - else nilSeq[Compiled[_]] + else nilSeq[Compiled[?]] } val ordered = Dag.topologicalSort(locals)( _.dependencies.flatMap(dep => - if (dep.key.isLocal) Seq[Compiled[_]](compiled(dep)) - else nilSeq[Compiled[_]] + if (dep.key.isLocal) Seq[Compiled[?]](compiled(dep)) + else nilSeq[Compiled[?]] ) ) def flatten( - cmap: Map[ScopedKey[_], Flattened], - key: ScopedKey[_], - deps: Iterable[ScopedKey[_]] + cmap: Map[ScopedKey[?], Flattened], + key: ScopedKey[?], + deps: Iterable[ScopedKey[?]] ): Flattened = new Flattened( key, - deps.flatMap(dep => if (dep.key.isLocal) cmap(dep).dependencies else Seq[ScopedKey[_]](dep)) + deps.flatMap(dep => if (dep.key.isLocal) cmap(dep).dependencies else Seq[ScopedKey[?]](dep)) ) - val empty = Map.empty[ScopedKey[_], Flattened] + val empty = Map.empty[ScopedKey[?], Flattened] val flattenedLocals = ordered.foldLeft(empty) { (cmap, c) => cmap.updated(c.key, flatten(cmap, c.key, c.dependencies)) } compiled flatMap { case (key, comp) => - if (key.key.isLocal) nilSeq[(ScopedKey[_], Flattened)] + if (key.key.isLocal) nilSeq[(ScopedKey[?], Flattened)] else - Seq[(ScopedKey[_], Flattened)]((key, flatten(flattenedLocals, key, comp.dependencies))) + Seq[(ScopedKey[?], Flattened)]((key, flatten(flattenedLocals, key, comp.dependencies))) } } - def definedAtString(settings: Seq[Setting[_]]): String = { + def definedAtString(settings: Seq[Setting[?]]): String = { val posDefined = settings.flatMap(_.positionString.toList) if (posDefined.nonEmpty) { val header = @@ -511,19 +511,19 @@ trait Init[ScopeType]: else if (delegates(s2).contains(s1)) Some(s2) // s2 is more specific else None - private def deriveAndLocal(init: Seq[Setting[_]], delegates: ScopeType => Delegates)(implicit + private def deriveAndLocal(init: Seq[Setting[?]], delegates: ScopeType => Delegates)(implicit scopeLocal: ScopeLocal - ): Seq[Setting[_]] = { + ): Seq[Setting[?]] = { import collection.mutable - final class Derived(val setting: DerivedSetting[_]) { + final class Derived(val setting: DerivedSetting[?]) { val dependencies = setting.dependencies.map(_.key) def triggeredBy = dependencies.filter(setting.trigger) val inScopes = new mutable.HashSet[ScopeType] - val outputs = new mutable.ListBuffer[Setting[_]] + val outputs = new mutable.ListBuffer[Setting[?]] } - final class Deriveds(val key: AttributeKey[_], val settings: mutable.ListBuffer[Derived]) { + final class Deriveds(val key: AttributeKey[?], val settings: mutable.ListBuffer[Derived]) { def dependencies = settings.flatMap(_.dependencies) // This is mainly for use in the cyclic reference error message override def toString = @@ -532,40 +532,40 @@ trait Init[ScopeType]: // separate `derived` settings from normal settings (`defs`) val (derived, rawDefs) = - Util.separate[Setting[_], Derived, Setting[_]](init) { + Util.separate[Setting[?], Derived, Setting[?]](init) { case d: DerivedSetting[_] => Left(new Derived(d)); case s => Right(s) } val defs = addLocal(rawDefs)(scopeLocal) // group derived settings by the key they define - val derivsByDef = new mutable.HashMap[AttributeKey[_], Deriveds] + val derivsByDef = new mutable.HashMap[AttributeKey[?], Deriveds] for (s <- derived) { val key = s.setting.key.key derivsByDef.getOrElseUpdate(key, new Deriveds(key, new mutable.ListBuffer)).settings += s } // index derived settings by triggering key. This maps a key to the list of settings potentially derived from it. - val derivedBy = new mutable.HashMap[AttributeKey[_], mutable.ListBuffer[Derived]] + val derivedBy = new mutable.HashMap[AttributeKey[?], mutable.ListBuffer[Derived]] for (s <- derived; d <- s.triggeredBy) derivedBy.getOrElseUpdate(d, new mutable.ListBuffer) += s // Map a DerivedSetting[_] to the `Derived` struct wrapping it. Used to ultimately replace a DerivedSetting with // the `Setting`s that were actually derived from it: `Derived.outputs` - val derivedToStruct: Map[DerivedSetting[_], Derived] = (derived map { s => + val derivedToStruct: Map[DerivedSetting[?], Derived] = (derived map { s => s.setting -> s }).toMap // set of defined scoped keys, used to ensure a derived setting is only added if all dependencies are present - val defined = new mutable.HashSet[ScopedKey[_]] - def addDefs(ss: Seq[Setting[_]]): Unit = { for (s <- ss) defined += s.key } + val defined = new mutable.HashSet[ScopedKey[?]] + def addDefs(ss: Seq[Setting[?]]): Unit = { for (s <- ss) defined += s.key } addDefs(defs) // true iff the scoped key is in `defined`, taking delegation into account - def isDefined(key: AttributeKey[_], scope: ScopeType) = + def isDefined(key: AttributeKey[?], scope: ScopeType) = delegates(scope).exists(s => defined.contains(ScopedKey(s, key))) // true iff all dependencies of derived setting `d` have a value (potentially via delegation) in `scope` - def allDepsDefined(d: Derived, scope: ScopeType, local: Set[AttributeKey[_]]): Boolean = + def allDepsDefined(d: Derived, scope: ScopeType, local: Set[AttributeKey[?]]): Boolean = d.dependencies.forall(dep => local(dep) || isDefined(dep, scope)) // Returns the list of injectable derived settings and their local settings for `sk`. @@ -578,10 +578,10 @@ trait Init[ScopeType]: // 2. it applies to outputScope (as determined by its `filter`) // 3. all of its dependencies are defined for outputScope (allowing for delegation) // This needs to handle local settings because a derived setting wouldn't be injected if it's local setting didn't exist yet. - val deriveFor = (sk: ScopedKey[_]) => { + val deriveFor = (sk: ScopedKey[?]) => { val derivedForKey: List[Derived] = derivedBy.get(sk.key).toList.flatten val scope = sk.scope - def localAndDerived(d: Derived): Seq[Setting[_]] = { + def localAndDerived(d: Derived): Seq[Setting[?]] = { def definingScope = d.setting.key.scope val outputScope = intersectDelegates(scope, definingScope, delegates) outputScope collect { @@ -598,10 +598,10 @@ trait Init[ScopeType]: derivedForKey.flatMap(localAndDerived) } - val processed = new mutable.HashSet[ScopedKey[_]] + val processed = new mutable.HashSet[ScopedKey[?]] // derives settings, transitively so that a derived setting can trigger another - def process(rem: List[Setting[_]]): Unit = rem match { + def process(rem: List[Setting[?]]): Unit = rem match { case s :: ss => val sk = s.key val ds = if (processed.add(sk)) deriveFor(sk) else nil @@ -640,7 +640,7 @@ trait Init[ScopeType]: * @tparam A1 the type of the value this defines. */ sealed trait Initialize[A1]: - def dependencies: Seq[ScopedKey[_]] + def dependencies: Seq[ScopedKey[?]] def apply[A2](g: A1 => A2): Initialize[A2] private[sbt] def mapReferenced(g: MapScoped): Initialize[A1] @@ -681,16 +681,16 @@ trait Init[ScopeType]: end Initialize object SettingsDefinition: - implicit def unwrapSettingsDefinition(d: SettingsDefinition): Seq[Setting[_]] = d.settings - implicit def wrapSettingsDefinition(ss: Seq[Setting[_]]): SettingsDefinition = + implicit def unwrapSettingsDefinition(d: SettingsDefinition): Seq[Setting[?]] = d.settings + implicit def wrapSettingsDefinition(ss: Seq[Setting[?]]): SettingsDefinition = new SettingList(ss) end SettingsDefinition sealed trait SettingsDefinition: - def settings: Seq[Setting[_]] + def settings: Seq[Setting[?]] end SettingsDefinition - final class SettingList(override val settings: Seq[Setting[_]]) extends SettingsDefinition + final class SettingList(override val settings: Seq[Setting[?]]) extends SettingsDefinition sealed class Setting[A1] private[Init] ( val key: ScopedKey[A1], @@ -699,20 +699,20 @@ trait Init[ScopeType]: ) extends SettingsDefinition: override def settings = this :: Nil def definitive: Boolean = !init.dependencies.contains(key) - def dependencies: Seq[ScopedKey[_]] = + def dependencies: Seq[ScopedKey[?]] = remove(init.dependencies.asInstanceOf[Seq[ScopedKey[A1]]], key) - def mapReferenced(g: MapScoped): Setting[A1] = make(key, init mapReferenced g, pos) + def mapReferenced(g: MapScoped): Setting[A1] = make(key, init.mapReferenced(g), pos) def validateReferenced(g: ValidateRef): Either[Seq[Undefined], Setting[A1]] = - (init validateReferenced g).map(newI => make(key, newI, pos)) + init.validateReferenced(g).map(newI => make(key, newI, pos)) private[sbt] def validateKeyReferenced(g: ValidateKeyRef): Either[Seq[Undefined], Setting[A1]] = - (init validateKeyReferenced g).map(newI => make(key, newI, pos)) + init.validateKeyReferenced(g).map(newI => make(key, newI, pos)) def mapKey(g: MapScoped): Setting[A1] = make(g(key), init, pos) def mapInit(f: (ScopedKey[A1], A1) => A1): Setting[A1] = make(key, init(t => f(key, t)), pos) - def mapConstant(g: MapConstant): Setting[A1] = make(key, init mapConstant g, pos) + def mapConstant(g: MapConstant): Setting[A1] = make(key, init.mapConstant(g), pos) def withPos(pos: SourcePosition) = make(key, init, pos) def positionString: Option[String] = pos match @@ -744,7 +744,7 @@ trait Init[ScopeType]: i: Initialize[A1], p: SourcePosition, val filter: ScopeType => Boolean, - val trigger: AttributeKey[_] => Boolean + val trigger: AttributeKey[?] => Boolean ) extends Setting[A1](sk, i, p): override def make[B](key: ScopedKey[B], init: Initialize[B], pos: SourcePosition): Setting[B] = @@ -764,7 +764,7 @@ trait Init[ScopeType]: val id: Long override def make[B](key: ScopedKey[B], init: Initialize[B], pos: SourcePosition): Setting[B] = - super.make(key, init, pos) default id + super.make(key, init, pos).default(id) override final def hashCode = id.hashCode @@ -801,7 +801,7 @@ trait Init[ScopeType]: (fa: Initialize[A]) => (fa.mapConstant(g)) private def evaluateK(g: Settings[ScopeType]): [A] => Initialize[A] => A = [A] => (fa: Initialize[A]) => (fa.evaluate(g)) - private def deps(ls: List[Initialize[_]]): Seq[ScopedKey[_]] = + private def deps(ls: List[Initialize[?]]): Seq[ScopedKey[?]] = ls.flatMap(_.dependencies) /** @@ -847,7 +847,7 @@ trait Init[ScopeType]: private[sbt] final class TransformCapture(val f: [x] => Initialize[x] => Initialize[x]) extends Initialize[[x] => Initialize[x] => Initialize[x]]: - override def dependencies: Seq[ScopedKey[_]] = Nil + override def dependencies: Seq[ScopedKey[?]] = Nil override def apply[A2](g2: ([x] => Initialize[x] => Initialize[x]) => A2): Initialize[A2] = map(this)(g2) override def evaluate(ss: Settings[ScopeType]): [x] => Initialize[x] => Initialize[x] = f @@ -867,7 +867,7 @@ trait Init[ScopeType]: private[sbt] final class ValidationCapture[A1](val key: ScopedKey[A1], val selfRefOk: Boolean) extends Initialize[ScopedKey[A1]]: - override def dependencies: Seq[ScopedKey[_]] = Nil + override def dependencies: Seq[ScopedKey[?]] = Nil override def apply[A2](g2: ScopedKey[A1] => A2): Initialize[A2] = map(this)(g2) override def evaluate(ss: Settings[ScopeType]): ScopedKey[A1] = key override def mapReferenced(g: MapScoped): Initialize[ScopedKey[A1]] = @@ -885,19 +885,19 @@ trait Init[ScopeType]: private[sbt] final class Bind[S, A1](val f: S => Initialize[A1], val in: Initialize[S]) extends Initialize[A1]: - override def dependencies: Seq[ScopedKey[_]] = in.dependencies + override def dependencies: Seq[ScopedKey[?]] = in.dependencies override def apply[A2](g: A1 => A2): Initialize[A2] = Bind[S, A2](s => f(s)(g), in) - override def evaluate(ss: Settings[ScopeType]): A1 = f(in evaluate ss) evaluate ss + override def evaluate(ss: Settings[ScopeType]): A1 = f(in.evaluate(ss)).evaluate(ss) override def mapReferenced(g: MapScoped) = - Bind[S, A1](s => f(s) mapReferenced g, in mapReferenced g) + Bind[S, A1](s => f(s).mapReferenced(g), in.mapReferenced(g)) - override def validateKeyReferenced(g: ValidateKeyRef) = (in validateKeyReferenced g).map { - validIn => - Bind[S, A1](s => handleUndefined(f(s) validateKeyReferenced g), validIn) - } + override def validateKeyReferenced(g: ValidateKeyRef) = + in.validateKeyReferenced(g).map { validIn => + Bind[S, A1](s => handleUndefined(f(s).validateKeyReferenced(g)), validIn) + } override def mapConstant(g: MapConstant) = - Bind[S, A1](s => f(s) mapConstant g, in mapConstant g) + Bind[S, A1](s => f(s).mapConstant(g), in.mapConstant(g)) private[sbt] override def processAttributes[A2](init: A2)(f: (A2, AttributeMap) => A2): A2 = in.processAttributes(init)(f) @@ -905,7 +905,7 @@ trait Init[ScopeType]: private[sbt] final class Optional[S, A1](val a: Option[Initialize[S]], val f: Option[S] => A1) extends Initialize[A1]: - override def dependencies: Seq[ScopedKey[_]] = deps(a.toList) + override def dependencies: Seq[ScopedKey[?]] = deps(a.toList) override def apply[A2](g: A1 => A2): Initialize[A2] = new Optional[S, A2](a, g compose f) override def mapReferenced(g: MapScoped): Initialize[A1] = @@ -930,7 +930,7 @@ trait Init[ScopeType]: end Optional private[sbt] final class Value[A1](val value: () => A1) extends Initialize[A1]: - override def dependencies: Seq[ScopedKey[_]] = Nil + override def dependencies: Seq[ScopedKey[?]] = Nil override def mapReferenced(g: MapScoped): Initialize[A1] = this override def validateKeyReferenced(g: ValidateKeyRef): ValidatedInit[A1] = Right(this) override def apply[A2](g: A1 => A2): Initialize[A2] = Value[A2](() => g(value())) @@ -941,7 +941,7 @@ trait Init[ScopeType]: end Value private[sbt] object StaticScopes extends Initialize[Set[ScopeType]]: - override def dependencies: Seq[ScopedKey[_]] = Nil + override def dependencies: Seq[ScopedKey[?]] = Nil override def mapReferenced(g: MapScoped): Initialize[Set[ScopeType]] = this override def validateKeyReferenced(g: ValidateKeyRef): ValidatedInit[Set[ScopeType]] = Right(this) @@ -954,7 +954,7 @@ trait Init[ScopeType]: private[sbt] final class Uniform[A1, A2](val f: Seq[A1] => A2, val inputs: List[Initialize[A1]]) extends Initialize[A2]: - override def dependencies: Seq[ScopedKey[_]] = deps(inputs) + override def dependencies: Seq[ScopedKey[?]] = deps(inputs) override def mapReferenced(g: MapScoped): Initialize[A2] = Uniform(f, inputs.map(_.mapReferenced(g))) override def mapConstant(g: MapConstant): Initialize[A2] = @@ -978,7 +978,7 @@ trait Init[ScopeType]: ) extends Initialize[A1]: import sbt.internal.util.TupleMapExtension.* - override def dependencies: Seq[ScopedKey[_]] = deps(inputs.toList0) + override def dependencies: Seq[ScopedKey[?]] = deps(inputs.toList0) override def mapReferenced(g: MapScoped): Initialize[A1] = Apply(f, inputs.transform(mapReferencedK(g))) override def mapConstant(g: MapConstant): Initialize[A1] = @@ -1001,9 +1001,9 @@ trait Init[ScopeType]: private def remove[A](s: Seq[A], v: A) = s.filterNot(_ == v) - final class Undefined private[sbt] (val defining: Setting[_], val referencedKey: ScopedKey[_]) + final class Undefined private[sbt] (val defining: Setting[?], val referencedKey: ScopedKey[?]) - def Undefined(defining: Setting[_], referencedKey: ScopedKey[_]): Undefined = + def Undefined(defining: Setting[?], referencedKey: ScopedKey[?]): Undefined = new Undefined(defining, referencedKey) final class RuntimeUndefined(val undefined: Seq[Undefined]) @@ -1014,7 +1014,7 @@ trait Init[ScopeType]: }.mkString end RuntimeUndefined - private final class InvalidReference(val key: ScopedKey[_]) + private final class InvalidReference(val key: ScopedKey[?]) extends RuntimeException( "Internal settings error: invalid reference to " + showFullKey.show(key) ) diff --git a/util-collection/src/test/scala/SettingsExample.scala b/util-collection/src/test/scala/SettingsExample.scala index 23065ebb6..32ead8616 100644 --- a/util-collection/src/test/scala/SettingsExample.scala +++ b/util-collection/src/test/scala/SettingsExample.scala @@ -21,7 +21,7 @@ final case class Scope(nestIndex: Int, idAtIndex: Int = 0) // That would be a general pain.) case class SettingsExample() extends Init[Scope] { // Provides a way of showing a Scope+AttributeKey[_] - val showFullKey: Show[ScopedKey[_]] = Show[ScopedKey[_]]((key: ScopedKey[_]) => { + val showFullKey: Show[ScopedKey[?]] = Show[ScopedKey[?]]((key: ScopedKey[?]) => { s"${key.scope.nestIndex}(${key.scope.idAtIndex})/${key.key.label}" }) @@ -55,7 +55,7 @@ case class SettingsUsage(val settingsExample: SettingsExample) { val b4 = ScopedKey(Scope(4), b) // Define some settings - val mySettings: Seq[Setting[_]] = Seq( + val mySettings: Seq[Setting[?]] = Seq( setting(a3, value(3)), setting(b4, a4(_ * 3)), update(a5)(_ + 1) diff --git a/util-tracking/src/main/scala/sbt/util/Tracked.scala b/util-tracking/src/main/scala/sbt/util/Tracked.scala index 789e6032a..3324e1e1c 100644 --- a/util-tracking/src/main/scala/sbt/util/Tracked.scala +++ b/util-tracking/src/main/scala/sbt/util/Tracked.scala @@ -397,7 +397,8 @@ class Difference( private def clearCache() = store.delete() - private def cachedFilesInfo = store.read(default = FilesInfo.empty[style.F])(style.formats).files + private def cachedFilesInfo = + store.read(default = FilesInfo.empty[style.F])(using style.formats).files private def raw(fs: Set[style.F]): Set[File] = fs.map(_.file) def apply[T](files: Set[File])(f: ChangeReport[File] => T): T = { @@ -432,7 +433,7 @@ class Difference( val result = f(report) val info = if (filesAreOutputs) style(abs(extractFiles(result))) else currentFilesInfo - store.write(info)(style.formats) + store.write(info)(using style.formats) result } diff --git a/util-tracking/src/test/scala/sbt/util/TrackedSpec.scala b/util-tracking/src/test/scala/sbt/util/TrackedSpec.scala index ad24cf535..1b27796f5 100644 --- a/util-tracking/src/test/scala/sbt/util/TrackedSpec.scala +++ b/util-tracking/src/test/scala/sbt/util/TrackedSpec.scala @@ -29,7 +29,7 @@ class TrackedSpec extends AnyFlatSpec { in case (_, Some(_)) => fail() - }(implicitly)(value) + }(using implicitly)(value) assert(res0 === value) val res1 = @@ -40,7 +40,7 @@ class TrackedSpec extends AnyFlatSpec { assert(in === otherValue) assert(read === value) read - }(implicitly)(otherValue) + }(using implicitly)(otherValue) assert(res1 === value) val res2 = @@ -51,7 +51,7 @@ class TrackedSpec extends AnyFlatSpec { assert(in === otherValue) assert(read === value) read - }(implicitly)(otherValue) + }(using implicitly)(otherValue) assert(res2 === value) () @@ -90,7 +90,7 @@ class TrackedSpec extends AnyFlatSpec { in case (false, _) => fail() - }(implicitly, implicitly)(input0) + }(using implicitly, implicitly)(input0) assert(res0 === input0) val res1 = @@ -100,7 +100,7 @@ class TrackedSpec extends AnyFlatSpec { case (false, in) => assert(in === input0) in - }(implicitly, implicitly)(input0) + }(using implicitly, implicitly)(input0) assert(res1 === input0) () @@ -119,7 +119,7 @@ class TrackedSpec extends AnyFlatSpec { in case (false, _) => fail() - }(implicitly, implicitly)(input0) + }(using implicitly, implicitly)(input0) assert(res0 === input0) val res1 = @@ -129,7 +129,7 @@ class TrackedSpec extends AnyFlatSpec { in case (false, _) => fail() - }(implicitly, implicitly)(input1) + }(using implicitly, implicitly)(input1) assert(res1 === input1) () @@ -180,7 +180,7 @@ class TrackedSpec extends AnyFlatSpec { firstExpectedResult case (false, _) => fail() - }(implicitly)(p0) + }(using implicitly)(p0) assert(res0 === firstExpectedResult) val res1 = @@ -190,7 +190,7 @@ class TrackedSpec extends AnyFlatSpec { case (false, in) => assert(in === afterCompletion) secondExpectedResult - }(implicitly)(p0) + }(using implicitly)(p0) assert(res1 === secondExpectedResult) () diff --git a/zinc-lm-integration/src/main/scala/sbt/internal/inc/ZincLmUtil.scala b/zinc-lm-integration/src/main/scala/sbt/internal/inc/ZincLmUtil.scala index 1c8979f84..6dd17a783 100644 --- a/zinc-lm-integration/src/main/scala/sbt/internal/inc/ZincLmUtil.scala +++ b/zinc-lm-integration/src/main/scala/sbt/internal/inc/ZincLmUtil.scala @@ -99,11 +99,11 @@ object ZincLmUtil { .withConfigurations(Some(Compile.name)) } else { val compilerBridgeId = scalaVersion match { - case sc if sc startsWith "2.10." => "compiler-bridge_2.10" - case sc if sc startsWith "2.11." => "compiler-bridge_2.11" - case sc if sc startsWith "2.12." => "compiler-bridge_2.12" - case "2.13.0-M1" => "compiler-bridge_2.12" - case _ => "compiler-bridge_2.13" + case sc if sc.startsWith("2.10.") => "compiler-bridge_2.10" + case sc if sc.startsWith("2.11.") => "compiler-bridge_2.11" + case sc if sc.startsWith("2.12.") => "compiler-bridge_2.12" + case "2.13.0-M1" => "compiler-bridge_2.12" + case _ => "compiler-bridge_2.13" } ModuleID(SbtOrganization, compilerBridgeId, ZincComponentManager.version) .withConfigurations(Some(Compile.name)) From 130853277bae22c0c555770d8825164c33e0d498 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 28 Oct 2024 00:01:51 -0400 Subject: [PATCH 2/2] Remove -Ykind-projector --- project/HouseRulesPlugin.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/project/HouseRulesPlugin.scala b/project/HouseRulesPlugin.scala index 3314c25fd..1a4061636 100644 --- a/project/HouseRulesPlugin.scala +++ b/project/HouseRulesPlugin.scala @@ -23,7 +23,6 @@ object HouseRulesPlugin extends AutoPlugin { }) .value .toList, - scalacOptions ++= "-Ykind-projector".ifScala3.value.toList, scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList, scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList, scalacOptions ++= "-Ywarn-dead-code".ifScala2.value.toList,