Skip to content

Commit b3aae68

Browse files
authored
Merge pull request sbt#6711 from xuwei-k/fix-scala-2-13-warn
fix Scala 2.13 warnings
2 parents ad6f07b + 535b15b commit b3aae68

File tree

51 files changed

+99
-99
lines changed

Some content is hidden

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

51 files changed

+99
-99
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ lazy val serverTestProj = (project in file("server-test"))
11041104
val rawClasspath =
11051105
(Compile / fullClasspathAsJars).value.map(_.data).mkString(java.io.File.pathSeparator)
11061106
val cp =
1107-
if (scala.util.Properties.isWin) rawClasspath.replaceAllLiterally("\\", "\\\\")
1107+
if (scala.util.Properties.isWin) rawClasspath.replace("\\", "\\\\")
11081108
else rawClasspath
11091109
val content = {
11101110
s"""|

internal/util-collection/src/main/scala/sbt/internal/util/HList.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final case class HCons[H, T <: HList](head: H, tail: T) extends HList {
3030
type Wrap[M[_]] = M[H] :+: T#Wrap[M]
3131
def :+:[G](g: G): G :+: H :+: T = HCons(g, this)
3232

33-
override def toString = head + " :+: " + tail.toString
33+
override def toString = head.toString + " :+: " + tail.toString
3434
}
3535

3636
object HList {

internal/util-collection/src/main/scala/sbt/internal/util/Settings.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private final class Settings0[ScopeType](
4343
(data get scope).flatMap(_ get key)
4444

4545
def set[T](scope: ScopeType, key: AttributeKey[T], value: T): Settings[ScopeType] = {
46-
val map = data getOrElse (scope, AttributeMap.empty)
46+
val map = data.getOrElse(scope, AttributeMap.empty)
4747
val newData = data.updated(scope, map.put(key, value))
4848
new Settings0(newData, delegates)
4949
}
@@ -476,7 +476,7 @@ trait Init[ScopeType] {
476476
if (posDefined.size == settings.size) "defined at:"
477477
else
478478
"some of the defining occurrences:"
479-
header + (posDefined.distinct mkString ("\n\t", "\n\t", "\n"))
479+
header + (posDefined.distinct.mkString("\n\t", "\n\t", "\n"))
480480
} else ""
481481
}
482482

@@ -711,10 +711,10 @@ trait Init[ScopeType] {
711711
def mapReferenced(g: MapScoped): Setting[T] = make(key, init mapReferenced g, pos)
712712

713713
def validateReferenced(g: ValidateRef): Either[Seq[Undefined], Setting[T]] =
714-
(init validateReferenced g).right.map(newI => make(key, newI, pos))
714+
(init validateReferenced g).map(newI => make(key, newI, pos))
715715

716716
private[sbt] def validateKeyReferenced(g: ValidateKeyRef): Either[Seq[Undefined], Setting[T]] =
717-
(init validateKeyReferenced g).right.map(newI => make(key, newI, pos))
717+
(init validateKeyReferenced g).map(newI => make(key, newI, pos))
718718

719719
def mapKey(g: MapScoped): Setting[T] = make(g(key), init, pos)
720720
def mapInit(f: (ScopedKey[T], T) => T): Setting[T] = make(key, init(t => f(key, t)), pos)
@@ -879,9 +879,8 @@ trait Init[ScopeType] {
879879
def evaluate(ss: Settings[ScopeType]): T = f(in evaluate ss) evaluate ss
880880
def mapReferenced(g: MapScoped) = new Bind[S, T](s => f(s) mapReferenced g, in mapReferenced g)
881881

882-
def validateKeyReferenced(g: ValidateKeyRef) = (in validateKeyReferenced g).right.map {
883-
validIn =>
884-
new Bind[S, T](s => handleUndefined(f(s) validateKeyReferenced g), validIn)
882+
def validateKeyReferenced(g: ValidateKeyRef) = (in validateKeyReferenced g).map { validIn =>
883+
new Bind[S, T](s => handleUndefined(f(s) validateKeyReferenced g), validIn)
885884
}
886885

887886
def mapConstant(g: MapConstant) = new Bind[S, T](s => f(s) mapConstant g, in mapConstant g)
@@ -898,7 +897,7 @@ trait Init[ScopeType] {
898897

899898
def validateKeyReferenced(g: ValidateKeyRef) = a match {
900899
case None => Right(this)
901-
case Some(i) => Right(new Optional(i.validateKeyReferenced(g).right.toOption, f))
900+
case Some(i) => Right(new Optional(i.validateKeyReferenced(g).toOption, f))
902901
}
903902

904903
def mapConstant(g: MapConstant): Initialize[T] = new Optional(a map mapConstantT(g).fn, f)

internal/util-collection/src/main/scala/sbt/internal/util/Util.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object Util {
4343
def camelToHyphen(s: String): String =
4444
Camel.replaceAllIn(s, m => m.group(1) + "-" + m.group(2).toLowerCase(Locale.ENGLISH))
4545

46-
def quoteIfKeyword(s: String): String = if (ScalaKeywords.values(s)) '`' + s + '`' else s
46+
def quoteIfKeyword(s: String): String = if (ScalaKeywords.values(s)) s"`${s}`" else s
4747

4848
def ignoreResult[T](f: => T): Unit = macro Macro.ignore
4949

internal/util-complete/src/main/scala/sbt/internal/util/complete/Parser.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ private final class StringLiteral(str: String, start: Int) extends ValidParser[S
909909
if (str.charAt(start) == c) stringLiteral(str, start + 1) else new Invalid(resultEmpty)
910910

911911
def completions(level: Int) = Completions.single(Completion.suggestion(str.substring(start)))
912-
override def toString = '"' + str + '"'
912+
override def toString = "\"" + str + "\""
913913
}
914914

915915
private final class CharacterClass(f: Char => Boolean, label: String) extends ValidParser[Char] {

internal/util-complete/src/main/scala/sbt/internal/util/complete/Parsers.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ trait Parsers {
238238
val notDelim = charClass(c => c != open && c != close).*.string
239239
def impl(): Parser[String] = {
240240
(open ~ (notDelim ~ close).?).flatMap {
241-
case (l, Some((content, r))) => Parser.success(l + content + r)
241+
case (l, Some((content, r))) => Parser.success(s"$l$content$r")
242242
case (l, None) =>
243243
((notDelim ~ impl()).map {
244244
case (leftPrefix, nestedBraces) => leftPrefix + nestedBraces
245245
}.+ ~ notDelim ~ close).map {
246-
case ((nested, suffix), r) => l + nested.mkString + suffix + r
246+
case ((nested, suffix), r) => s"$l${nested.mkString}$suffix$r"
247247
}
248248
}
249249
}

internal/util-logging/src/main/scala/sbt/internal/util/GlobalLogging.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ object GlobalLogging {
8383
): GlobalLogging = {
8484
val loggerName = generateName
8585
val log = LoggerContext.globalContext.logger(loggerName, None, None)
86-
val appender = ConsoleAppender(ConsoleAppender.generateName, console)
86+
val appender = ConsoleAppender(ConsoleAppender.generateName(), console)
8787
LoggerContext.globalContext.addAppender(loggerName, appender -> Level.Info)
8888
GlobalLogging(log, console, appender, GlobalLogBacking(newBackingFile), newAppender)
8989
}

internal/util-logging/src/main/scala/sbt/internal/util/MainAppender.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ object MainAppender {
6767
)
6868

6969
def defaultScreen(console: ConsoleOut): Appender =
70-
ConsoleAppender(ConsoleAppender.generateName, console)
70+
ConsoleAppender(ConsoleAppender.generateName(), console)
7171

7272
def defaultScreen(
7373
console: ConsoleOut,
7474
suppressedMessage: SuppressedTraceContext => Option[String]
7575
): Appender = {
7676
ConsoleAppender(
77-
ConsoleAppender.generateName,
77+
ConsoleAppender.generateName(),
7878
console,
7979
suppressedMessage = suppressedMessage
8080
)
@@ -99,7 +99,7 @@ object MainAppender {
9999
def defaultBacked(loggerName: String, useFormat: Boolean): PrintWriter => Appender =
100100
to => {
101101
ConsoleAppender(
102-
ConsoleAppender.generateName,
102+
ConsoleAppender.generateName(),
103103
ConsoleOut.printWriterOut(to),
104104
useFormat = useFormat
105105
)

internal/util-logging/src/main/scala/sbt/internal/util/ProgressState.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ private[sbt] final class ProgressState(
9999
addBytes(terminal, bytes)
100100
val toWrite = new ArrayBuffer[Byte]
101101
terminal.prompt match {
102-
case a: Prompt.AskUser if a.render.nonEmpty && canClearPrompt => toWrite ++= cleanPrompt
103-
case _ =>
102+
case a: Prompt.AskUser if a.render().nonEmpty && canClearPrompt => toWrite ++= cleanPrompt
103+
case _ =>
104104
}
105105
val endsWithNewLine = bytes.endsWith(lineSeparatorBytes)
106106
if (endsWithNewLine || bytes.containsSlice(lineSeparatorBytes)) {

internal/util-logging/src/main/scala/sbt/internal/util/Terminal.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ object Terminal {
905905
new AtomicReference[((Int, Int), Deadline)](((1, 1), Deadline.now - 1.day))
906906
private[this] def setSize() = size.set((Try(getSizeImpl).getOrElse((1, 1)), Deadline.now))
907907
private[this] def getSize = size.get match {
908-
case (s, d) if (d + sizeRefreshPeriod).isOverdue =>
908+
case (s, d) if (d + sizeRefreshPeriod).isOverdue() =>
909909
setSize()
910910
size.get._1
911911
case (s, _) => s

internal/util-logging/src/main/scala/sbt/internal/util/WindowsInputStream.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private[util] class WindowsInputStream(term: org.jline.terminal.Terminal, in: In
5656
private val SHIFT_PRESSED = 0x0010;
5757
private def getCapability(cap: Capability): String = term.getStringCapability(cap) match {
5858
case null => null
59-
case c => c.replaceAllLiterally("\\E", "\u001B")
59+
case c => c.replace("\\E", "\u001B")
6060
}
6161
/*
6262
* This function is a hybrid of jline 2 WindowsTerminal.readConsoleInput

internal/util-logging/src/test/scala/Escapes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ object Escapes extends Properties("Escapes") {
9696
)
9797
}
9898
assert(isEscapeTerminator(terminator))
99-
def makeString: String = ESC + content + terminator
99+
def makeString: String = s"$ESC$content$terminator"
100100

101101
override def toString =
102102
if (content.isEmpty) s"ESC (${terminator.toInt})"

internal/util-relation/src/main/scala/sbt/internal/util/Relation.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,5 @@ private final class MRelation[A, B](fwd: Map[A, Set[B]], rev: Map[B, Set[A]])
214214
override def hashCode = fwd.filterNot(_._2.isEmpty).hashCode()
215215

216216
override def toString =
217-
all.map { case (a, b) => a + " -> " + b }.mkString("Relation [", ", ", "]")
217+
all.map { case (a, b) => s"$a -> $b" }.mkString("Relation [", ", ", "]")
218218
}

internal/util-scripted/src/main/scala/sbt/internal/scripted/FileCommands.scala

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import java.io.File
1313
import sbt.io.{ IO, Path }
1414
import sbt.io.syntax._
1515
import Path._
16-
import sbt.io.IO
1716

1817
class FileCommands(baseDirectory: File) extends BasicStatementHandler {
1918
lazy val commands = commandMap
@@ -25,19 +24,19 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
2524
"mkdir" nonEmpty makeDirectories _,
2625
"absent" nonEmpty absent _,
2726
// "sync" twoArg("Two directory paths", sync _),
28-
"newer" twoArg ("Two paths", newer _),
27+
"newer".twoArg("Two paths", newer _),
2928
"pause" noArg {
3029
println("Pausing in " + baseDirectory)
3130
/*readLine("Press enter to continue. ") */
3231
print("Press enter to continue. ")
3332
System.console.readLine
3433
println()
3534
},
36-
"sleep" oneArg ("Time in milliseconds", time => Thread.sleep(time.toLong)),
35+
"sleep".oneArg("Time in milliseconds", time => Thread.sleep(time.toLong)),
3736
"exec" nonEmpty (execute _),
3837
"copy" copy (to => rebase(baseDirectory, to)),
39-
"copy-file" twoArg ("Two paths", copyFile _),
40-
"must-mirror" twoArg ("Two paths", diffFiles _),
38+
"copy-file".twoArg("Two paths", copyFile _),
39+
"must-mirror".twoArg("Two paths", diffFiles _),
4140
"copy-flat" copy flat
4241
)
4342

internal/util-scripted/src/main/scala/sbt/internal/scripted/ScriptedTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ final class ScriptedTests(
103103
log: ManagedLogger,
104104
context: LoggerContext,
105105
): Seq[() => Option[String]] = {
106-
for (groupDir <- (resourceBaseDirectory * group).get; nme <- (groupDir * name).get) yield {
106+
for (groupDir <- (resourceBaseDirectory * group).get(); nme <- (groupDir * name).get()) yield {
107107
val g = groupDir.getName
108108
val n = nme.getName
109109
val str = s"$g / $n"

launcher-package/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ val root = (project in file(".")).
273273
case (k, BinSbt) =>
274274
import java.nio.file.{Files, FileSystems}
275275
val x = IO.read(k)
276-
IO.write(t / "sbt", x.replaceAllLiterally(
276+
IO.write(t / "sbt", x.replace(
277277
"declare init_sbt_version=_to_be_replaced",
278278
s"declare init_sbt_version=$sbtVersionToRelease"))
279279

main-actions/src/main/scala/sbt/ForkTests.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private[sbt] object ForkTests {
162162
RunningProcesses.add(p)
163163
val ec = try p.exitValue()
164164
finally {
165-
if (p.isAlive) p.destroy()
165+
if (p.isAlive()) p.destroy()
166166
RunningProcesses.remove(p)
167167
}
168168
val result =
@@ -223,7 +223,7 @@ private final class React(
223223
listeners.foreach(_ testEvent event)
224224
val suiteResult = SuiteResult(tEvents)
225225
results += group -> suiteResult
226-
listeners.foreach(_ endGroup (group, suiteResult.result))
226+
listeners.foreach(_.endGroup(group, suiteResult.result))
227227
react()
228228
}
229229
}

main-actions/src/main/scala/sbt/Package.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object Package {
8888
for ((key, value) <- mergeManifest.getEntries.asScala) {
8989
entryMap.get(key) match {
9090
case Some(attributes) => mergeAttributes(attributes, value); ()
91-
case None => entryMap put (key, value); ()
91+
case None => entryMap.put(key, value); ()
9292
}
9393
}
9494
}

main-actions/src/main/scala/sbt/RawCompileLike.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object RawCompileLike {
6565
log.debug("Uptodate: " + outputDirectory.getAbsolutePath)
6666
}
6767
}
68-
cachedComp(inputs)(exists(outputDirectory.allPaths.get.toSet))
68+
cachedComp(inputs)(exists(outputDirectory.allPaths.get().toSet))
6969
}
7070

7171
def prepare(description: String, doCompile: Gen): Gen =

main-actions/src/main/scala/sbt/compiler/Eval.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ final class Eval(
265265
if (phase == null || phase == phase.next || evalReporter.hasErrors)
266266
()
267267
else {
268-
enteringPhase(phase) { phase.run }
268+
enteringPhase(phase) { phase.run() }
269269
compile(phase.next)
270270
}
271271
}

main-actions/src/test/scala/sbt/CacheIvyTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CacheIvyTest extends Properties("CacheIvy") {
8585
for {
8686
o <- Gen.identifier
8787
n <- Gen.identifier
88-
r <- for { n <- Gen.numChar; ns <- Gen.numStr } yield n + ns
88+
r <- for { n <- Gen.numChar; ns <- Gen.numStr } yield s"$n$ns"
8989
cs <- arbitrary[Option[String]]
9090
branch <- arbitrary[Option[String]]
9191
isChanging <- arbitrary[Boolean]

main-command/src/main/scala/sbt/BasicCommands.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ object BasicCommands {
153153
private[this] def completionsParser: Parser[String] = {
154154
val notQuoted = (NotQuoted ~ any.*) map { case (nq, s) => nq + s }
155155
val quotedOrUnquotedSingleArgument = Space ~> (StringVerbatim | StringEscapable | notQuoted)
156-
token(quotedOrUnquotedSingleArgument ?? "" examples ("", " "))
156+
token((quotedOrUnquotedSingleArgument ?? "").examples("", " "))
157157
}
158158

159159
def runCompletions(state: State)(input: String): State = {
@@ -199,7 +199,7 @@ object BasicCommands {
199199
val it = s.iterator
200200
var fail = false
201201
while (it.hasNext && !fail) {
202-
it.next match {
202+
it.next() match {
203203
case "" => fail = it.hasNext; ()
204204
case next => result += next; ()
205205
}

main-command/src/main/scala/sbt/CommandUtil.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ object CommandUtil {
8888
}
8989

9090
def layoutDetails(details: Map[String, String]): String =
91-
details.map { case (k, v) => k + "\n\n " + v } mkString ("\n", "\n\n", "\n")
91+
details.map { case (k, v) => k + "\n\n " + v }.mkString("\n", "\n\n", "\n")
9292

9393
final val HelpPatternFlags = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE
9494

9595
private[sbt] def isSbtBuild(baseDir: File) =
96-
(baseDir / "project").exists() || (baseDir * "*.sbt").get.nonEmpty
96+
(baseDir / "project").exists() || (baseDir * "*.sbt").get().nonEmpty
9797
}

main-command/src/main/scala/sbt/internal/LegacyWatched.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private[sbt] object LegacyWatched {
4444
(ClearOnFailure :: next :: FailureWall :: repeat :: s)
4545
.put(ContinuousEventMonitor, monitor: EventMonitor)
4646
case Some(eventMonitor) =>
47-
Watched.printIfDefined(watched watchingMessage eventMonitor.state)
47+
Watched.printIfDefined(watched watchingMessage eventMonitor.state())
4848
@tailrec def impl(): State = {
4949
val triggered = try eventMonitor.awaitEvent()
5050
catch {
@@ -56,7 +56,7 @@ private[sbt] object LegacyWatched {
5656
false
5757
}
5858
if (triggered) {
59-
Watched.printIfDefined(watched triggeredMessage eventMonitor.state)
59+
Watched.printIfDefined(watched triggeredMessage eventMonitor.state())
6060
ClearOnFailure :: next :: FailureWall :: repeat :: s
6161
} else if (shouldTerminate) {
6262
while (System.in.available() > 0) System.in.read()

main-command/src/main/scala/sbt/internal/client/NetworkClient.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class NetworkClient(
380380
}
381381
if (!startServer) {
382382
val deadline = 5.seconds.fromNow
383-
while (socket.isEmpty && !deadline.isOverdue) {
383+
while (socket.isEmpty && !deadline.isOverdue()) {
384384
socket = Try(ClientSocket.localSocket(bootSocketName, useJNI)).toOption
385385
if (socket.isEmpty) Thread.sleep(20)
386386
}
@@ -836,12 +836,12 @@ class NetworkClient(
836836
case -1 => (query, query, None, None) // shouldn't happen
837837
case i =>
838838
val rawPrefix = query.substring(0, i)
839-
val prefix = rawPrefix.replaceAllLiterally("\"", "").replaceAllLiterally("\\;", ";")
840-
val rawSuffix = query.substring(i).replaceAllLiterally("\\;", ";")
839+
val prefix = rawPrefix.replace("\"", "").replace("\\;", ";")
840+
val rawSuffix = query.substring(i).replace("\\;", ";")
841841
val suffix = if (rawSuffix.length > 1) rawSuffix.substring(1) else ""
842842
(rawPrefix, prefix, Some(rawSuffix), Some(suffix))
843843
}
844-
} else (query, query.replaceAllLiterally("\\;", ";"), None, None)
844+
} else (query, query.replace("\\;", ";"), None, None)
845845
val tailSpace = query.endsWith(" ") || query.endsWith("\"")
846846
val sanitizedQuery = suffix.foldLeft(prefix) { _ + _ }
847847
def getCompletions(query: String, sendCommand: Boolean): Seq[String] = {
@@ -885,7 +885,7 @@ class NetworkClient(
885885
}
886886
getCompletions(sanitizedQuery, true) collect {
887887
case c if inQuote => c
888-
case c if tailSpace && c.contains(" ") => c.replaceAllLiterally(prefix, "")
888+
case c if tailSpace && c.contains(" ") => c.replace(prefix, "")
889889
case c if !tailSpace => c.split(" ").last
890890
}
891891
}
@@ -1106,10 +1106,10 @@ object NetworkClient {
11061106
launchJar = a
11071107
.split("--sbt-launch-jar=")
11081108
.lastOption
1109-
.map(_.replaceAllLiterally("%20", " "))
1109+
.map(_.replace("%20", " "))
11101110
case "--sbt-launch-jar" if i + 1 < sanitized.length =>
11111111
i += 1
1112-
launchJar = Option(sanitized(i).replaceAllLiterally("%20", " "))
1112+
launchJar = Option(sanitized(i).replace("%20", " "))
11131113
case "-bsp" | "--bsp" => bsp = true
11141114
case a if !a.startsWith("-") => commandArgs += a
11151115
case a @ SysProp(key, value) =>
@@ -1131,7 +1131,7 @@ object NetworkClient {
11311131
sbtArguments.toSeq,
11321132
commandArgs.toSeq,
11331133
completionArguments.toSeq,
1134-
sbtScript.getOrElse(defaultSbtScript).replaceAllLiterally("%20", " "),
1134+
sbtScript.getOrElse(defaultSbtScript).replace("%20", " "),
11351135
bsp,
11361136
launchJar
11371137
)

0 commit comments

Comments
 (0)