Skip to content

Commit a2d7ec1

Browse files
authored
NIT Fix more miscellaneous warnings (#3920)
1 parent 3e12222 commit a2d7ec1

File tree

47 files changed

+129
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+129
-138
lines changed

modules/build-macros/src/main/scala/scala/build/EitherCps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package scala.build
22

3-
final case class EitherFailure[E](v: E, cps: EitherCps[_]) extends RuntimeException:
3+
final case class EitherFailure[E](v: E, cps: EitherCps[?]) extends RuntimeException:
44
override def fillInStackTrace() = this // disable stack trace generation
55

66
class EitherCps[E]
77

88
object EitherCps:
99
def value[E, V](using
10-
cps: EitherCps[_ >: E]
10+
cps: EitherCps[? >: E]
1111
)(from: Either[E, V]) = // Adding a context bounds breaks incremental compilation
1212
from match
1313
case Left(e) => throw EitherFailure(e, cps)

modules/build/src/main/scala/scala/build/Build.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import scala.build.options.validation.ValidationException
2222
import scala.build.postprocessing.*
2323
import scala.build.postprocessing.LineConversion.scalaLineToScLineShift
2424
import scala.collection.mutable.ListBuffer
25+
import scala.compiletime.uninitialized
2526
import scala.concurrent.duration.DurationInt
2627
import scala.util.Properties
2728
import scala.util.control.NonFatal
@@ -1303,7 +1304,7 @@ object Build {
13031304
}
13041305

13051306
private val lock = new Object
1306-
private var f: ScheduledFuture[?] = _
1307+
private var f: ScheduledFuture[?] = uninitialized
13071308
private val waitFor = 50.millis
13081309
private val runnable: Runnable = { () =>
13091310
lock.synchronized {

modules/build/src/main/scala/scala/build/CrossSources.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final case class CrossSources(
5252
buildOptions
5353
.filter(_.requirements.isEmpty)
5454
.map(_.value)
55-
.foldLeft(baseOptions)(_ orElse _)
55+
.foldLeft(baseOptions)(_.orElse(_))
5656

5757
private def needsScalaVersion =
5858
paths.exists(_.needsScalaVersion) ||
@@ -80,7 +80,7 @@ final case class CrossSources(
8080
.flatMap(_.withScalaVersion(retainedScalaVersion).toSeq)
8181
.filter(_.requirements.isEmpty)
8282
.map(_.value)
83-
.foldLeft(sharedOptions0)(_ orElse _)
83+
.foldLeft(sharedOptions0)(_.orElse(_))
8484

8585
val platform = buildOptionsWithScalaVersion.platform
8686

@@ -246,7 +246,7 @@ object CrossSources {
246246
scopedRequirementsByRoot
247247
.getOrElse(path.root, Nil)
248248
.flatMap(_.valueFor(path).toSeq)
249-
.foldLeft(BuildRequirements())(_ orElse _)
249+
.foldLeft(BuildRequirements())(_.orElse(_))
250250

251251
// Scala CLI treats all `.test.scala` files tests as well as
252252
// files from within `test` subdirectory from provided input directories
@@ -266,7 +266,7 @@ object CrossSources {
266266
} yield {
267267
val baseReqs0 = baseReqs(preprocessedSource.scopePath)
268268
preprocessedSource.optionsWithTargetRequirements :+ WithBuildRequirements(
269-
preprocessedSource.requirements.fold(baseReqs0)(_ orElse baseReqs0),
269+
preprocessedSource.requirements.fold(baseReqs0)(_.orElse(baseReqs0)),
270270
opts
271271
)
272272
}).flatten
@@ -281,7 +281,7 @@ object CrossSources {
281281
case d: PreprocessedSource.OnDisk =>
282282
val baseReqs0 = baseReqs(d.scopePath)
283283
WithBuildRequirements(
284-
d.requirements.fold(baseReqs0)(_ orElse baseReqs0),
284+
d.requirements.fold(baseReqs0)(_.orElse(baseReqs0)),
285285
(d.path, d.path.relativeTo(allInputs.workspace))
286286
) -> d.directivesPositions
287287
}
@@ -291,7 +291,7 @@ object CrossSources {
291291
case m: PreprocessedSource.InMemory =>
292292
val baseReqs0 = baseReqs(m.scopePath)
293293
WithBuildRequirements(
294-
m.requirements.fold(baseReqs0)(_ orElse baseReqs0),
294+
m.requirements.fold(baseReqs0)(_.orElse(baseReqs0)),
295295
Sources.InMemory(m.originalPath, m.relPath, m.content, m.wrapperParamsOpt)
296296
) -> m.directivesPositions
297297
}
@@ -301,7 +301,7 @@ object CrossSources {
301301
case m: PreprocessedSource.UnwrappedScript =>
302302
val baseReqs0 = baseReqs(m.scopePath)
303303
WithBuildRequirements(
304-
m.requirements.fold(baseReqs0)(_ orElse baseReqs0),
304+
m.requirements.fold(baseReqs0)(_.orElse(baseReqs0)),
305305
Sources.UnwrappedScript(m.originalPath, m.relPath, m.wrapScriptFun)
306306
) -> m.directivesPositions
307307
}

modules/build/src/main/scala/scala/build/Project.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ final case class Project(
116116

117117
def writeBloopFile(strictCheck: Boolean, logger: Logger): Boolean = {
118118
lazy val bloopFileContent =
119-
writeAsJsonToArray(bloopFile)(BloopCodecs.codecFile)
119+
writeAsJsonToArray(bloopFile)(using BloopCodecs.codecFile)
120120
val dest = directory / ".bloop" / s"$projectName.json"
121121
val doWrite =
122122
if (strictCheck)

modules/build/src/main/scala/scala/build/ScopedSources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ final case class ScopedSources(
121121
*/
122122
def combinedBuildOptions(scope: Scope, baseOptions: BuildOptions): BuildOptions =
123123
buildOptionsFor(scope)
124-
.foldRight(baseOptions)(_ orElse _)
124+
.foldRight(baseOptions)(_.orElse(_))
125125

126126
def buildInfo(baseOptions: BuildOptions, workspace: os.Path): Either[BuildException, BuildInfo] =
127127
either {

modules/build/src/main/scala/scala/build/bsp/BspImpl.scala

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import scala.build.input.{Inputs, ScalaCliInvokeData}
2424
import scala.build.internal.Constants
2525
import scala.build.options.{BuildOptions, Scope}
2626
import scala.collection.mutable.ListBuffer
27+
import scala.compiletime.uninitialized
2728
import scala.concurrent.duration.DurationInt
2829
import scala.concurrent.{ExecutionContext, Future, Promise}
2930
import scala.jdk.CollectionConverters.*
@@ -55,9 +56,9 @@ final class BspImpl(
5556

5657
private val shownGlobalMessages =
5758
new java.util.concurrent.ConcurrentHashMap[String, Unit]()
58-
private var actualLocalClient: BspClient = _
59-
private var localClient: b.BuildClient with BloopBuildClient = _
60-
private val bloopSession = new BloopSession.Reference
59+
private var actualLocalClient: BspClient = uninitialized
60+
private var localClient: b.BuildClient & BloopBuildClient = uninitialized
61+
private val bloopSession = new BloopSession.Reference
6162

6263
/** Sends the buildTarget/didChange BSP notification to the BSP client, indicating that the build
6364
* targets defined in the current session have changed.
@@ -386,7 +387,7 @@ final class BspImpl(
386387
* @return
387388
* BSP client
388389
*/
389-
private def getLocalClient(verbosity: Int): b.BuildClient with BloopBuildClient =
390+
private def getLocalClient(verbosity: Int): b.BuildClient & BloopBuildClient =
390391
if (verbosity >= 3)
391392
new BspImpl.LoggingBspClient(actualLocalClient)
392393
else
@@ -464,22 +465,18 @@ final class BspImpl(
464465
val currentBloopSession = newBloopSession(initialInputs, initialBspOptions)
465466
bloopSession.update(null, currentBloopSession, "BSP server already initialized")
466467

467-
val actualLocalServer: b.BuildServer
468-
with b.ScalaBuildServer
469-
with b.JavaBuildServer
470-
with b.JvmBuildServer
471-
with ScalaScriptBuildServer
472-
with HasGeneratedSources = new BuildServerProxy(
473-
() => bloopSession.get().bspServer,
474-
() => onReload()
475-
)
468+
val actualLocalServer: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer
469+
& ScalaScriptBuildServer & HasGeneratedSources =
470+
new BuildServerProxy(
471+
() => bloopSession.get().bspServer,
472+
() => onReload()
473+
)
476474

477-
val localServer: b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer
478-
with b.JvmBuildServer with ScalaScriptBuildServer =
479-
if (verbosity >= 3)
480-
new LoggingBuildServerAll(actualLocalServer)
481-
else
482-
actualLocalServer
475+
val localServer: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer
476+
& ScalaScriptBuildServer =
477+
if verbosity >= 3
478+
then new LoggingBuildServerAll(actualLocalServer)
479+
else actualLocalServer
483480

484481
val launcher = new jsonrpc.Launcher.Builder[b.BuildClient]()
485482
.setExecutorService(threads.buildThreads.bloop.jsonrpc) // FIXME No
@@ -530,10 +527,10 @@ final class BspImpl(
530527

531528
val es = ExecutionContext.fromExecutorService(threads.buildThreads.bloop.jsonrpc)
532529
val futures = Seq(
533-
BspImpl.naiveJavaFutureToScalaFuture(f).map(_ => ())(es),
530+
BspImpl.naiveJavaFutureToScalaFuture(f).map(_ => ())(using es),
534531
currentBloopSession.bspServer.initiateShutdown
535532
)
536-
Future.firstCompletedOf(futures)(es)
533+
Future.firstCompletedOf(futures)(using es)
537534
}
538535

539536
/** Shuts down the current Bloop session */
@@ -592,7 +589,7 @@ final class BspImpl(
592589
// RelodableOptions don't take into account buildOptions from sources
593590
val updatedReloadableOptions = reloadableOptions.copy(
594591
buildOptions =
595-
reloadableOptions.buildOptions orElse preBuildProject.mainScope.buildOptions,
592+
reloadableOptions.buildOptions.orElse(preBuildProject.mainScope.buildOptions),
596593
bloopRifleConfig = reloadableOptions.bloopRifleConfig.copy(
597594
javaPath = projectJavaHome.javaCommand,
598595
minimumBloopJvm = projectJavaHome.version
@@ -643,7 +640,7 @@ final class BspImpl(
643640
if (os.isFile(ideInputsJsonPath)) {
644641
val maybeResponse = either[BuildException] {
645642
val ideInputs = value {
646-
try Right(readFromArray(os.read.bytes(ideInputsJsonPath))(IdeInputs.codec))
643+
try Right(readFromArray(os.read.bytes(ideInputsJsonPath))(using IdeInputs.codec))
647644
catch {
648645
case e: JsonReaderException =>
649646
logger.debug(s"Caught $e while decoding $ideInputsJsonPath")

modules/build/src/main/scala/scala/build/bsp/LoggingBuildServerAll.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import ch.epfl.scala.bsp4j as b
55
import java.util.concurrent.CompletableFuture
66

77
class LoggingBuildServerAll(
8-
val underlying: b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer with b.JvmBuildServer
9-
with ScalaScriptBuildServer
8+
val underlying: b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer & ScalaScriptBuildServer
109
) extends LoggingBuildServer with LoggingScalaBuildServer with LoggingJavaBuildServer
1110
with LoggingJvmBuildServer
1211
with ScalaScriptBuildServer {

modules/build/src/main/scala/scala/build/internal/Runner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ object Runner {
8787
sys.error("should not happen")
8888
}
8989
else {
90-
val b = new ProcessBuilder(command: _*)
90+
val b = new ProcessBuilder(command*)
9191
.inheritIO()
9292

9393
if (!inheritStreams) {
@@ -332,7 +332,7 @@ object Runner {
332332
sys.error("should not happen")
333333
}
334334
else {
335-
val builder = new ProcessBuilder(command: _*)
335+
val builder = new ProcessBuilder(command*)
336336
.inheritIO()
337337
val env = builder.environment()
338338
for ((k, v) <- extraEnv)

modules/build/src/main/scala/scala/build/internal/util/WarningMessages.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ object WarningMessages {
8383
): String =
8484
powerFeatureUsedInSip(optionName, "option", specificationLevel)
8585

86-
def powerConfigKeyUsedInSip(key: Key[_])(using ScalaCliInvokeData): String =
86+
def powerConfigKeyUsedInSip(key: Key[?])(using ScalaCliInvokeData): String =
8787
powerFeatureUsedInSip(key.fullName, "configuration key", key.specificationLevel)
8888

8989
def powerDirectiveUsedInSip(
9090
directive: ScopedDirective,
91-
handler: DirectiveHandler[_]
91+
handler: DirectiveHandler[?]
9292
)(using ScalaCliInvokeData): String =
9393
powerFeatureUsedInSip(
9494
directive.directive.toString,

modules/build/src/main/scala/scala/build/preprocessing/ExtractedDirectives.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object ExtractedDirectives {
6565
}
6666

6767
val strictDirectives = directivesOpt.toSeq.flatMap { directives =>
68-
def toStrictValue(value: UsingValue): Seq[Value[_]] = value match {
68+
def toStrictValue(value: UsingValue): Seq[Value[?]] = value match {
6969
case uvs: UsingValues => uvs.values.asScala.toSeq.flatMap(toStrictValue)
7070
case el: EmptyLiteral => Seq(EmptyValue(el))
7171
case sl: StringLiteral => Seq(StringValue(sl.getValue(), sl))

0 commit comments

Comments
 (0)