Skip to content

Commit c0b3e58

Browse files
committed
Merge pull request scala#2327 from paulp/pr/2315-rebased
SI-7261 Implicit conversion of BooleanSetting to Boolean and BooleanFlag
2 parents 4c85fb3 + 22944e4 commit c0b3e58

File tree

95 files changed

+251
-244
lines changed

Some content is hidden

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

95 files changed

+251
-244
lines changed

src/compiler/scala/reflect/macros/runtime/Reifiers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ trait Reifiers {
6060
def logFreeVars(symtab: SymbolTable): Unit =
6161
// logging free vars only when they are untyped prevents avalanches of duplicate messages
6262
symtab.syms map (sym => symtab.symDef(sym)) foreach {
63-
case FreeTermDef(_, _, binding, _, origin) if universe.settings.logFreeTerms.value && binding.tpe == null =>
63+
case FreeTermDef(_, _, binding, _, origin) if universe.settings.logFreeTerms && binding.tpe == null =>
6464
reporter.echo(position, "free term: %s %s".format(showRaw(binding), origin))
65-
case FreeTypeDef(_, _, binding, _, origin) if universe.settings.logFreeTypes.value && binding.tpe == null =>
65+
case FreeTypeDef(_, _, binding, _, origin) if universe.settings.logFreeTypes && binding.tpe == null =>
6666
reporter.echo(position, "free type: %s %s".format(showRaw(binding), origin))
6767
case _ =>
6868
// do nothing
6969
}
7070

71-
if (universe.settings.logFreeTerms.value || universe.settings.logFreeTypes.value)
71+
if (universe.settings.logFreeTerms || universe.settings.logFreeTypes)
7272
reification match {
7373
case ReifiedTree(_, _, symtab, _, _, _, _) => logFreeVars(symtab)
7474
case ReifiedType(_, _, symtab, _, _, _) => logFreeVars(symtab)

src/compiler/scala/reflect/reify/Phases.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ trait Phases extends Reshape
2525
if (reifyDebug) println("[reshape phase]")
2626
tree = reshape.transform(tree)
2727
if (reifyDebug) println("[interlude]")
28-
if (reifyDebug) println("reifee = " + (if (settings.Xshowtrees.value || settings.XshowtreesCompact.value || settings.XshowtreesStringified.value) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString))
28+
if (reifyDebug) println("reifee = " + (if (settings.Xshowtrees || settings.XshowtreesCompact || settings.XshowtreesStringified) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString))
2929

3030
if (reifyDebug) println("[calculate phase]")
3131
calculate.traverse(tree)

src/compiler/scala/reflect/reify/Reifier.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ abstract class Reifier extends States
5757

5858
val result = reifee match {
5959
case tree: Tree =>
60-
reifyTrace("reifying = ")(if (settings.Xshowtrees.value || settings.XshowtreesCompact.value || settings.XshowtreesStringified.value) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString)
60+
reifyTrace("reifying = ")(if (settings.Xshowtrees || settings.XshowtreesCompact || settings.XshowtreesStringified) "\n" + nodePrinters.nodeToString(tree).trim else tree.toString)
6161
reifyTrace("reifee is located at: ")(tree.pos)
6262
reifyTrace("universe = ")(universe)
6363
reifyTrace("mirror = ")(mirror)
@@ -140,4 +140,4 @@ abstract class Reifier extends States
140140
throw new UnexpectedReificationException(defaultErrorPosition, "reification crashed", ex)
141141
}
142142
}
143-
}
143+
}

src/compiler/scala/tools/nsc/CompileClient.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ class StandardCompileClient extends HasCompileSocket with CompileOutputCommon {
2626
val settings = new FscSettings(Console.println)
2727
val command = new OfflineCompilerCommand(args.toList, settings)
2828
val shutdown = settings.shutdown.value
29-
val extraVmArgs = if (settings.preferIPv4.value) List("-D%s=true".format(preferIPv4Stack.key)) else Nil
29+
val extraVmArgs = if (settings.preferIPv4) List("-D%s=true".format(preferIPv4Stack.key)) else Nil
3030

3131
val vmArgs = settings.jvmargs.unparse ++ settings.defines.unparse ++ extraVmArgs
3232
val fscArgs = args.toList ++ command.extraFscArgs
3333

34-
if (settings.version.value) {
34+
if (settings.version) {
3535
Console println versionMsg
3636
return true
3737
}

src/compiler/scala/tools/nsc/Driver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class Driver {
4141
command = new CompilerCommand(args.toList, ss)
4242
settings = command.settings
4343

44-
if (settings.version.value) {
44+
if (settings.version) {
4545
reporter.echo(versionMsg)
4646
} else if (processSettingsHook()) {
4747
val compiler = newCompiler()

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
221221
def inform(msg: String) = reporter.echo(msg)
222222
override def globalError(msg: String) = reporter.error(NoPosition, msg)
223223
override def warning(msg: String) =
224-
if (settings.fatalWarnings.value) globalError(msg)
224+
if (settings.fatalWarnings) globalError(msg)
225225
else reporter.warning(NoPosition, msg)
226226

227227
// Getting in front of Predef's asserts to supplement with more info.
@@ -252,7 +252,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
252252
}
253253

254254
@inline final def ifDebug(body: => Unit) {
255-
if (settings.debug.value)
255+
if (settings.debug)
256256
body
257257
}
258258
/** This is for WARNINGS which should reach the ears of scala developers
@@ -262,7 +262,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
262262
* to make them visually distinct.
263263
*/
264264
@inline final override def devWarning(msg: => String) {
265-
if (settings.developer.value || settings.debug.value)
265+
if (settings.developer || settings.debug)
266266
warning("!!! " + msg)
267267
else
268268
log("!!! " + msg) // such warnings always at least logged
@@ -272,7 +272,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
272272
msg + " in " + (currentTime - start) + "ms"
273273

274274
def informComplete(msg: String): Unit = reporter.withoutTruncating(inform(msg))
275-
def informProgress(msg: String) = if (settings.verbose.value) inform("[" + msg + "]")
275+
def informProgress(msg: String) = if (settings.verbose) inform("[" + msg + "]")
276276
def informTime(msg: String, start: Long) = informProgress(elapsedMessage(msg, start))
277277

278278
def logError(msg: String, t: Throwable): Unit = ()
@@ -287,7 +287,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
287287
}
288288

289289
@inline final override def debuglog(msg: => String) {
290-
if (settings.debug.value)
290+
if (settings.debug)
291291
log(msg)
292292
}
293293

@@ -332,7 +332,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
332332
}
333333
}
334334

335-
if (settings.verbose.value || settings.Ylogcp.value) {
335+
if (settings.verbose || settings.Ylogcp) {
336336
// Uses the "do not truncate" inform
337337
informComplete("[search path for source files: " + classPath.sourcepaths.mkString(",") + "]")
338338
informComplete("[search path for class files: " + classPath.asClasspathString + "]")
@@ -402,7 +402,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
402402
if ((unit ne null) && unit.exists)
403403
lastSeenSourceFile = unit.source
404404

405-
if (settings.debug.value && (settings.verbose.value || currentRun.size < 5))
405+
if (settings.debug && (settings.verbose || currentRun.size < 5))
406406
inform("[running phase " + name + " on " + unit + "]")
407407

408408
val unit0 = currentUnit
@@ -736,7 +736,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
736736
val maxName = (0 /: phaseNames)(_ max _.length)
737737
val width = maxName min Limit
738738
val maxDesc = MaxCol - (width + 6) // descriptions not novels
739-
val fmt = if (settings.verbose.value) s"%${maxName}s %2s %s%n"
739+
val fmt = if (settings.verbose) s"%${maxName}s %2s %s%n"
740740
else s"%${width}.${width}s %2s %.${maxDesc}s%n"
741741

742742
val line1 = fmt.format("phase name", "id", "description")
@@ -1097,7 +1097,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
10971097
val info3: List[String] = (
10981098
( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) )
10991099
++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) )
1100-
++ ( if (!settings.debug.value) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) )
1100+
++ ( if (!settings.debug) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) )
11011101
++ ( List(errorMessage) )
11021102
)
11031103

@@ -1113,18 +1113,18 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
11131113

11141114
def echoPhaseSummary(ph: Phase) = {
11151115
/* Only output a summary message under debug if we aren't echoing each file. */
1116-
if (settings.debug.value && !(settings.verbose.value || currentRun.size < 5))
1116+
if (settings.debug && !(settings.verbose || currentRun.size < 5))
11171117
inform("[running phase " + ph.name + " on " + currentRun.size + " compilation units]")
11181118
}
11191119

11201120
/** Collects for certain classes of warnings during this run. */
11211121
class ConditionalWarning(what: String, option: Settings#BooleanSetting) {
11221122
val warnings = mutable.LinkedHashMap[Position, String]()
11231123
def warn(pos: Position, msg: String) =
1124-
if (option.value) reporter.warning(pos, msg)
1124+
if (option) reporter.warning(pos, msg)
11251125
else if (!(warnings contains pos)) warnings += ((pos, msg))
11261126
def summarize() =
1127-
if (warnings.nonEmpty && (option.isDefault || settings.fatalWarnings.value))
1127+
if (warnings.nonEmpty && (option.isDefault || settings.fatalWarnings))
11281128
warning("there were %d %s warning(s); re-run with %s for details".format(warnings.size, what, option.name))
11291129
}
11301130

@@ -1240,7 +1240,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
12401240
def resetProjectClasses(root: Symbol): Unit = try {
12411241
def unlink(sym: Symbol) =
12421242
if (sym != NoSymbol) root.info.decls.unlink(sym)
1243-
if (settings.verbose.value) inform("[reset] recursing in "+root)
1243+
if (settings.verbose) inform("[reset] recursing in "+root)
12441244
val toReload = mutable.Set[String]()
12451245
for (sym <- root.info.decls) {
12461246
if (sym.isInitialized && clearOnNextRun(sym))
@@ -1260,7 +1260,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
12601260
for (fullname <- toReload)
12611261
classPath.findClass(fullname) match {
12621262
case Some(classRep) =>
1263-
if (settings.verbose.value) inform("[reset] reinit "+fullname)
1263+
if (settings.verbose) inform("[reset] reinit "+fullname)
12641264
loaders.initializeFromClassPath(root, classRep)
12651265
case _ =>
12661266
}
@@ -1453,7 +1453,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14531453
}
14541454

14551455
def reportCompileErrors() {
1456-
if (!reporter.hasErrors && reporter.hasWarnings && settings.fatalWarnings.value)
1456+
if (!reporter.hasErrors && reporter.hasWarnings && settings.fatalWarnings)
14571457
globalError("No warnings can be incurred under -Xfatal-warnings.")
14581458

14591459
if (reporter.hasErrors) {
@@ -1492,7 +1492,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14921492
def compileUnits(units: List[CompilationUnit], fromPhase: Phase) {
14931493
try compileUnitsInternal(units, fromPhase)
14941494
catch { case ex: Throwable =>
1495-
val shown = if (settings.verbose.value)
1495+
val shown = if (settings.verbose)
14961496
stackTraceString(ex)
14971497
else
14981498
stackTraceHeadString(ex) // note that error stacktraces do not print in fsc
@@ -1526,14 +1526,14 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
15261526
if (shouldWriteIcode) {
15271527
// Write *.icode files when -Xprint-icode or -Xprint:<some-optimiz-phase> was given.
15281528
writeICode()
1529-
} else if ((settings.Xprint containsPhase globalPhase) || settings.printLate.value && runIsAt(cleanupPhase)) {
1529+
} else if ((settings.Xprint containsPhase globalPhase) || settings.printLate && runIsAt(cleanupPhase)) {
15301530
// print trees
1531-
if (settings.Xshowtrees.value || settings.XshowtreesCompact.value || settings.XshowtreesStringified.value) nodePrinters.printAll()
1531+
if (settings.Xshowtrees || settings.XshowtreesCompact || settings.XshowtreesStringified) nodePrinters.printAll()
15321532
else printAllUnits()
15331533
}
15341534

15351535
// print the symbols presently attached to AST nodes
1536-
if (settings.Yshowsyms.value)
1536+
if (settings.Yshowsyms)
15371537
trackerFactory.snapshot()
15381538

15391539
// print members
@@ -1552,7 +1552,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
15521552
runCheckers()
15531553

15541554
// output collected statistics
1555-
if (settings.Ystatistics.value)
1555+
if (settings.Ystatistics)
15561556
statistics.print(phase)
15571557

15581558
advancePhase()
@@ -1697,7 +1697,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
16971697
informProgress("wrote " + file)
16981698
} catch {
16991699
case ex: IOException =>
1700-
if (settings.debug.value) ex.printStackTrace()
1700+
if (settings.debug) ex.printStackTrace()
17011701
globalError("could not write file " + file)
17021702
}
17031703
})

src/compiler/scala/tools/nsc/Main.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MainClass extends Driver with EvalLoop {
1717

1818
override def newCompiler(): Global = Global(settings, reporter)
1919
override def doCompile(compiler: Global) {
20-
if (settings.resident.value) resident(compiler)
20+
if (settings.resident) resident(compiler)
2121
else super.doCompile(compiler)
2222
}
2323
}

src/compiler/scala/tools/nsc/MainTokenMetric.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object MainTokenMetric {
4242
tokenMetric(compiler, command.files)
4343
} catch {
4444
case ex @ FatalError(msg) =>
45-
if (command.settings.debug.value)
45+
if (command.settings.debug)
4646
ex.printStackTrace()
4747
reporter.error(null, "fatal error: " + msg)
4848
}

src/compiler/scala/tools/nsc/ScriptRunner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ScriptRunner extends HasCompileSocket {
9595

9696
settings.outdir.value = compiledPath.path
9797

98-
if (settings.nc.value) {
98+
if (settings.nc) {
9999
/* Setting settings.script.value informs the compiler this is not a
100100
* self contained compilation unit.
101101
*/
@@ -114,7 +114,7 @@ class ScriptRunner extends HasCompileSocket {
114114
* not take place until there are no non-daemon threads running. Tickets #1955, #2006.
115115
*/
116116
util.waitingForThreads {
117-
if (settings.save.value) {
117+
if (settings.save) {
118118
val jarFile = jarFileFor(scriptFile)
119119
def jarOK = jarFile.canRead && (jarFile isFresher File(scriptFile))
120120

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class NodePrinters {
3232
}
3333

3434
trait DefaultPrintAST extends PrintAST {
35-
val printPos = settings.Xprintpos.value || settings.Yposdebug.value
35+
val printPos = settings.Xprintpos || settings.Yposdebug
3636

3737
def showNameAndPos(tree: NameTree) = showPosition(tree) + showName(tree.name)
3838
def showDefTreeName(tree: DefTree) = showName(tree.name)
@@ -100,9 +100,9 @@ abstract class NodePrinters {
100100

101101
def stringify(tree: Tree): String = {
102102
buf.clear()
103-
if (settings.XshowtreesStringified.value) buf.append(tree.toString + EOL)
104-
if (settings.XshowtreesCompact.value) {
105-
buf.append(showRaw(tree, printIds = settings.uniqid.value, printTypes = settings.printtypes.value))
103+
if (settings.XshowtreesStringified) buf.append(tree.toString + EOL)
104+
if (settings.XshowtreesCompact) {
105+
buf.append(showRaw(tree, printIds = settings.uniqid, printTypes = settings.printtypes))
106106
} else {
107107
level = 0
108108
traverse(tree)

0 commit comments

Comments
 (0)