8000 More unused fixes · scala/scala@8c00042 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c00042

Browse files
committed
More unused fixes
1 parent 060bc32 commit 8c00042

File tree

73 files changed

+281
-276
lines changed

Some content is hidden

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

73 files changed

+281
-276
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ lazy val compiler = configureAsSubproject(project)
538538
).get
539539
},
540540
Compile / scalacOptions ++= Seq(
541-
//"-Wunused", "-Wnonunit-statement",
541+
//"-Wunused", //"-Wnonunit-statement",
542542
"-Wconf:cat=deprecation&msg=early initializers:s", // compiler heavily relies upon early initializers
543543
),
544544
Compile / doc / scalacOptions ++= Seq(

src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract class DefaultMacroCompiler extends Resolvers
7171
val vanillaResult = tryCompile(vanillaImplRef)
7272
val bundleResult = tryCompile(bundleImplRef)
7373

74-
def ensureUnambiguousSuccess() = {
74+
def ensureUnambiguousSuccess(): Unit = {
7575
// we now face a hard choice of whether to report ambiguity:
7676
// 1) when there are eponymous methods in both bundle and object
7777
// 2) when both references to eponymous methods are resolved successfully
@@ -100,6 +100,7 @@ abstract class DefaultMacroCompiler extends Resolvers
100100
try {
101101
if (vanillaResult.isSuccess || bundleResult.isSuccess) ensureUnambiguousSuccess()
102102
if (vanillaResult.isFailure && bundleResult.isFailure) reportMostAppropriateFailure()
103+
//else // TODO
103104
vanillaResult.orElse(bundleResult).get
104105
} catch {
105106
case MacroImplResolutionException(pos, msg) =>

src/compiler/scala/reflect/reify/codegen/GenTypes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ trait GenTypes {
187187

188188
tpe match {
189189
case tpe @ RefinedType(parents, decls) =>
190-
reifySymDef(tpe.typeSymbol)
190+
List(tpe.typeSymbol).foreach(reifySymDef)
191191
mirrorBuildCall(nme.RefinedType, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
192192
case ExistentialType(tparams, underlying) =>
193193
tparams.foreach(reifySymDef)
194194
reifyBuildCall(nme.ExistentialType, tparams, underlying)
195195
case tpe @ ClassInfoType(parents, decls, clazz) =>
196-
reifySymDef(clazz)
196+
List(clazz).foreach(reifySymDef)
197197
mirrorBuildCall(nme.ClassInfoType, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
198198
case MethodType(params, restpe) =>
199199
params foreach reifySymDef

src/compiler/scala/reflect/reify/utils/SymbolTables.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
package scala.reflect.reify
1414
package utils
1515

16-
import scala.annotation.unused
16+
import scala.annotation._
1717
import scala.collection.{immutable, mutable}, mutable.{ArrayBuffer, ListBuffer}
1818
import java.lang.System.{lineSeparator => EOL}
1919

@@ -134,10 +134,11 @@ trait SymbolTables {
134134
s"""symtab = [$symtabString], aliases = [$aliasesString]${if (original.isDefined) ", has original" else ""}"""
135135
}
136136

137+
@nowarn // spurious unused buf.type
137138
def debugString: String = {
138139
val buf = new StringBuilder
139140
buf.append("symbol table = " + (if (syms.length == 0) "<empty>" else "")).append(EOL)
140-
syms foreach (sym => buf.append(symDef(sym)).append(EOL))
141+
syms.foreach(sym => buf.append(symDef(sym)).append(EOL))
141142
buf.delete(buf.length - EOL.length, buf.length)
142143
buf.toString
143144
}

src/compiler/scala/tools/nsc/ClassPathMemoryConsumptionTester.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ object ClassPathMemoryConsumptionTester {
4242
private def doTest(args: Array[String]) = {
4343
val settings = loadSettings(args.toList)
4444

45-
val mains = (1 to settings.requiredInstances.value) map (_ => new MainRetainsGlobal)
45+
val mains = (1 to settings.requiredInstances.value).map(_ => new MainRetainsGlobal)
4646

4747
// we need original settings without additional params to be able to use them later
4848
val baseArgs = argsWithoutRequiredInstances(args)
4949

5050
println(s"Loading classpath ${settings.requiredInstances.value} times")
5151
val startTime = System.currentTimeMillis()
5252

53-
mains map (_.process(baseArgs))
53+
mains.foreach(_.process(baseArgs))
5454

5555
val elapsed = System.currentTimeMillis() - startTime
5656
println(s"Operation finished - elapsed $elapsed ms")

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import java.io.{Closeable, FileNotFoundException, IOException}
1818
import java.net.URL
1919
import java.nio.charset.{Charset, CharsetDecoder, IllegalCharsetNameException, StandardCharsets, UnsupportedCharsetException}, StandardCharsets.UTF_8
2020

21-
import scala.annotation.{nowarn, tailrec}
21+
import scala.annotation._
2222
import scala.collection.{immutable, mutable}
2323
import scala.reflect.ClassTag
2424
import scala.reflect.internal.pickling.PickleBuffer
@@ -1470,6 +1470,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
14701470

14711471
private def showMembers() = {
14721472
// Allows for syntax like scalac -Xshow-class Random@erasure,typer
1473+
@nowarn
14731474
def splitClassAndPhase(str: String, term: Boolean): Name = {
14741475
def mkName(s: String) = if (term) newTermName(s) else newTypeName(s)
14751476
(str indexOf '@') match {

src/compiler/scala/tools/nsc/ast/NodePrinters.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ abstract class NodePrinters {
124124
}
125125
}
126126
def println(s: String) = printLine(s, "")
127+
def print(s: String) = buf.append(s)
127128

128129
def printLine(value: String, comment: String): Unit = {
129130
buf append " " * level
@@ -214,7 +215,7 @@ abstract class NodePrinters {
214215
}
215216

216217
def traverse(tree: Tree): Unit = {
217-
showPosition(tree)
218+
print(showPosition(tree))
218219

219220
tree match {
220221
case ApplyDynamic(fun, args) => applyCommon(tree, fun, args)
@@ -234,7 +235,7 @@ abstract class NodePrinters {
234235

235236
case ld @ LabelDef(name, params, rhs) =>
236237
printMultiline(tree) {
237-
showNameAndPos(ld)
238+
print(showNameAndPos(ld))
238239
traverseList("()", "params")(params)
239240
traverse(rhs)
240241
}

src/compiler/scala/tools/nsc/backend/jvm/opt/LocalOpt.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ object LocalOptImpls {
905905

906906
// Ensure the length of `renumber`. Unused variable indices are mapped to -1.
907907
val minLength = if (isWide) index + 2 else index + 1
908-
for (i <- renumber.length until minLength) renumber += -1
908+
for (_ <- renumber.length until minLength) renumber += -1
909909

910910
renumber(index) = index
911911
if (isWide) renumber(index + 1) = index
@@ -965,7 +965,7 @@ object LocalOptImpls {
965965
@tailrec
966966
def isEmpty(node: AbstractInsnNode): Boolean = node.getNext match {
967967
case null => true
968-
case l: LineNumberNode => true
968+
case _: LineNumberNode => true
969969
case n if n.getOpcode >= 0 => false
970970
case n => isEmpty(n)
971971
}

src/compiler/scala/tools/nsc/classpath/ClassPath.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
package scala.tools.nsc.classpath
1414

15+
import scala.annotation.unused
1516
import scala.reflect.io.AbstractFile
1617
import scala.tools.nsc.util.ClassRepresentation
1718

@@ -78,10 +79,10 @@ private[nsc] case class PackageEntryImpl(name: String) extends PackageEntry
7879

7980
private[nsc] trait NoSourcePaths {
8081
final def asSourcePathString: String = ""
81-
final private[nsc] def sources(inPackage: PackageName): Seq[SourceFileEntry] = Seq.empty
82+
final private[nsc] def sources(@unused inPackage: PackageName): Seq[SourceFileEntry] = Seq.empty
8283
}
8384

8485
private[nsc] trait NoClassPaths {
8586
final def findClassFile(className: String): Option[AbstractFile] = None
86-
private[nsc] final def classes(inPackage: PackageName): Seq[ClassFileEntry] = Seq.empty
87+
private[nsc] final def classes(@unused inPackage: PackageName): Seq[ClassFileEntry] = Seq.empty
8788
}

src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ final class FileBasedCache[K, T] {
252252
if (disableCache) Left("caching is disabled due to a policy setting")
253253
else if (!checkStamps) Right(paths)
254254
else {
255-
val nonJarZips = 82FF urlsAndFiles.filter { case (url, file) => file == null || !Jar.isJarOrZip(file.file) }
255+
val nonJarZips = urlsAndFiles.filter { case (_, file) => file == null || !Jar.isJarOrZip(file.file) }
256256
if (nonJarZips.nonEmpty) Left(s"caching is disabled because of the following classpath elements: ${nonJarZips.map(_._1).mkString(", ")}.")
257257
else Right(paths)
258258
}
@@ -267,7 +267,7 @@ final class FileBasedCache[K, T] {
267267
val fileKey = attrs.fileKey()
268268
Stamp(lastModified, attrs.size(), if (fileKey == null) NoFileKey else fileKey)
269269
} catch {
270-
case ex: java.nio.file.NoSuchFileException =>
270+
case _: java.nio.file.NoSuchFileException =>
271271
// Dummy stamp for (currently) non-existent file.
272272
Stamp(FileTime.fromMillis(0), -1, new Object)
273273
}

0 commit comments

Comments
 (0)
0