Skip to content

Commit a8c43dc

Browse files
committed
Cleanup and refactoring - semicolons, unused or commented out code
This commit contains some minor changes made by the way when implementing flat classpath. Sample JUnit test that shows that all pieces of JUnit infrastructure work correctly now uses assert method form JUnit as it should do from the beginning. I removed commented out lines which were obvious to me. In the case of less obvious commented out lines I added TODOs as someone should look at such places some day and clean them up. I removed also some unnecessary semicolons and unused imports. Many string concatenations using + have been changed to string interpolation. There's removed unused, private walkIterator method from ZipArchive. It seems that it was unused since this commit: scala@9d4994b However, I had to add an exception for the compatibility checker because it was complaining about this change. I made some trivial corrections/optimisations like use 'findClassFile' method instead of 'findClass' in combination with 'binary' to find the class file.
1 parent dfc5c1d commit a8c43dc

File tree

22 files changed

+75
-61
lines changed

22 files changed

+75
-61
lines changed

bincompat-backward.whitelist.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ filter {
203203
{
204204
matchName="scala.reflect.runtime.ThreadLocalStorage#MyThreadLocalStorage.values"
205205
problemName=MissingMethodProblem
206+
},
207+
// the below method was the unused private (sic!) method but the compatibility checker was complaining about it
208+
{
209+
matchName="scala.reflect.io.ZipArchive.scala$reflect$io$ZipArchive$$walkIterator"
210+
problemName=MissingMethodProblem
206211
}
207212
]
208213
}

bincompat-forward.whitelist.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,19 @@ filter {
301301
{
302302
matchName="scala.reflect.io.FileZipArchive.root"
303303
problemName=MissingMethodProblem
304+
},
305+
// introduced the harmless method (instead of the repeated code in several places)
306+
{
307+
matchName="scala.reflect.runtime.Settings#MultiStringSetting.valueSetByUser"
308+
problemName=MissingMethodProblem
309+
},
310+
{
311+
matchName="scala.reflect.runtime.Settings#BooleanSetting.valueSetByUser"
312+
problemName=MissingMethodProblem
313+
},
314+
{
315+
matchName="scala.reflect.runtime.Settings#IntSetting.valueSetByUser"
316+
problemName=MissingMethodProblem
304317
}
305318
]
306319
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
332332
None
333333
}
334334

335-
val charset = ( if (settings.encoding.isSetByUser) Some(settings.encoding.value) else None ) flatMap loadCharset getOrElse {
335+
val charset = settings.encoding.valueSetByUser flatMap loadCharset getOrElse {
336336
settings.encoding.value = defaultEncoding // A mandatory charset
337337
Charset.forName(defaultEncoding)
338338
}
@@ -347,7 +347,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
347347
}
348348
}
349349

350-
( if (settings.sourceReader.isSetByUser) Some(settings.sourceReader.value) else None ) flatMap loadReader getOrElse {
350+
settings.sourceReader.valueSetByUser flatMap loadReader getOrElse {
351351
new SourceReader(charset.newDecoder(), reporter)
352352
}
353353
}

src/compiler/scala/tools/nsc/PhaseAssembly.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ trait PhaseAssembly {
199199
// Add all phases in the set to the graph
200200
val graph = phasesSetToDepGraph(phasesSet)
201201

202-
val dot = if (settings.genPhaseGraph.isSetByUser) Some(settings.genPhaseGraph.value) else None
202+
val dot = settings.genPhaseGraph.valueSetByUser
203203

204204
// Output the phase dependency graph at this stage
205205
def dump(stage: Int) = dot foreach (n => graphToDotFile(graph, s"$n-$stage.dot"))

src/compiler/scala/tools/nsc/plugins/Plugins.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
package scala.tools.nsc
88
package plugins
99

10-
import scala.reflect.io.{ File, Path }
10+
import scala.reflect.io.Path
1111
import scala.tools.nsc.util.ClassPath
1212
import scala.tools.util.PathResolver.Defaults
1313

src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ abstract class SymbolLoaders {
8888
// require yjp.jar at runtime. See SI-2089.
8989
if (settings.termConflict.isDefault)
9090
throw new TypeError(
91-
root+" contains object and package with same name: "+
92-
name+"\none of them needs to be removed from classpath"
91+
s"$root contains object and package with same name: $name\none of them needs to be removed from classpath"
9392
)
9493
else if (settings.termConflict.value == "package") {
9594
warning(
@@ -252,7 +251,7 @@ abstract class SymbolLoaders {
252251
* Load contents of a package
253252
*/
254253
class PackageLoader(classpath: ClassPath[AbstractFile]) extends SymbolLoader with FlagAgnosticCompleter {
255-
protected def description = "package loader "+ classpath.name
254+
protected def description = s"package loader ${classpath.name}"
256255

257256
protected def doComplete(root: Symbol) {
258257
assert(root.isPackageClass, root)

src/compiler/scala/tools/nsc/transform/AddInterfaces.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure =>
351351
while (owner != sym && owner != impl) owner = owner.owner;
352352
if (owner == impl) This(impl) setPos tree.pos
353353
else tree
354+
//TODO what about this commented out code?
354355
/* !!!
355356
case Super(qual, mix) =>
356357
val mix1 = mix

src/compiler/scala/tools/reflect/ReflectMain.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package scala.tools
22
package reflect
33

4+
import scala.reflect.internal.util.ScalaClassLoader
45
import scala.tools.nsc.Driver
56
import scala.tools.nsc.Global
67
import scala.tools.nsc.Settings
7-
import scala.tools.nsc.util.ScalaClassLoader
88
import scala.tools.util.PathResolverFactory
99

1010
object ReflectMain extends Driver {

src/compiler/scala/tools/util/PathResolver.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ object PathResolver {
5151
/** Values found solely by inspecting environment or property variables.
5252
*/
5353
object Environment {
54-
private def searchForBootClasspath = (
54+
private def searchForBootClasspath =
5555
systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse ""
56-
)
5756

5857
/** Environment variables which java pays attention to so it
5958
* seems we do as well.
@@ -107,7 +106,7 @@ object PathResolver {
107106
else if (scalaLibAsDir.isDirectory) scalaLibAsDir.path
108107
else ""
109108

110-
// XXX It must be time for someone to figure out what all these things
109+
// TODO It must be time for someone to figure out what all these things
111110
// are intended to do. This is disabled here because it was causing all
112111
// the scala jars to end up on the classpath twice: one on the boot
113112
// classpath as set up by the runner (or regular classpath under -nobootcp)
@@ -177,7 +176,7 @@ object PathResolver {
177176
def fromPathString(path: String, context: JavaContext = DefaultJavaContext): JavaClassPath = {
178177
val s = new Settings()
179178
s.classpath.value = path
180-
new PathResolver(s, context) result
179+
new PathResolver(s, context).result
181180
}
182181

183182
/** With no arguments, show the interesting values in Environment and Defaults.
@@ -263,11 +262,9 @@ abstract class PathResolverBase[BaseClassPathType <: ClassFileLookup[AbstractFil
263262
* - Otherwise, if CLASSPATH is set, it is that
264263
* - If neither of those, then "." is used.
265264
*/
266-
def userClassPath = (
267-
if (!settings.classpath.isDefault)
268-
settings.classpath.value
265+
def userClassPath =
266+
if (!settings.classpath.isDefault) settings.classpath.value
269267
else sys.env.getOrElse("CLASSPATH", ".")
270-
)
271268

272269
import classPathFactory._
273270

@@ -291,7 +288,7 @@ abstract class PathResolverBase[BaseClassPathType <: ClassFileLookup[AbstractFil
291288
| javaBootClassPath = ${ppcp(javaBootClassPath)}
292289
| javaExtDirs = ${ppcp(javaExtDirs)}
293290
| javaUserClassPath = ${ppcp(javaUserClassPath)}
294-
| useJavaClassPath = $useJavaClassPath
291+
| useJavaClassPath = $useJavaClassPath
295292
| scalaBootClassPath = ${ppcp(scalaBootClassPath)}
296293
| scalaExtDirs = ${ppcp(scalaExtDirs)}
297294
| userClassPath = ${ppcp(userClassPath)}

src/interactive/scala/tools/nsc/interactive/Global.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
128128
else NullLogger
129129

130130
import log.logreplay
131-
debugLog("logger: " + log.getClass + " writing to " + (new java.io.File(logName)).getAbsolutePath)
132-
debugLog("classpath: "+classPath)
131+
debugLog(s"logger: ${log.getClass} writing to ${(new java.io.File(logName)).getAbsolutePath}")
132+
debugLog(s"classpath: $classPath")
133133

134134
private var curTime = System.nanoTime
135135
private def timeStep = {

0 commit comments

Comments
 (0)