Skip to content

Commit 1272298

Browse files
committed
no postfixops in nsc
1 parent e4b233d commit 1272298

File tree

15 files changed

+26
-43
lines changed

15 files changed

+26
-43
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import transform.patmat.PatternMatching
3636
import transform._
3737
import backend.{JavaPlatform, ScalaPrimitives}
3838
import backend.jvm.{BackendStats, GenBCode}
39-
import scala.language.postfixOps
4039
import scala.tools.nsc.ast.{TreeGen => AstTreeGen}
4140
import scala.tools.nsc.classpath._
4241
import scala.tools.nsc.profile.Profiler
@@ -756,7 +755,7 @@ class Global(var currentSettings: Settings, reporter0: LegacyReporter)
756755
private def phaseHelp(title: String, elliptically: Boolean, describe: SubComponent => String): String = {
757756
val Limit = 16 // phase names should not be absurdly long
758757
val MaxCol = 80 // because some of us edit on green screens
759-
val maxName = phaseNames map (_.length) max
758+
val maxName = phaseNames.map(_.length).max
760759
val width = maxName min Limit
761760
val maxDesc = MaxCol - (width + 6) // descriptions not novels
762761
val fmt = if (settings.verbose || !elliptically) s"%${maxName}s %2s %s%n"
@@ -806,13 +805,12 @@ class Global(var currentSettings: Settings, reporter0: LegacyReporter)
806805
/** Returns List of (phase, value) pairs, including only those
807806
* where the value compares unequal to the previous phase's value.
808807
*/
809-
def afterEachPhase[T](op: => T): List[(Phase, T)] = { // used in tests
808+
def afterEachPhase[T](op: => T): List[(Phase, T)] = // used in tests
810809
phaseDescriptors.map(_.ownPhase).filterNot(_ eq NoPhase).foldLeft(List[(Phase, T)]()) { (res, ph) =>
811810
val value = exitingPhase(ph)(op)
812811
if (res.nonEmpty && res.head._2 == value) res
813812
else ((ph, value)) :: res
814-
} reverse
815-
}
813+
}.reverse
816814

817815
// ------------ REPL utilities ---------------------------------
818816

@@ -1420,7 +1418,7 @@ class Global(var currentSettings: Settings, reporter0: LegacyReporter)
14201418
case -1 => mkName(str)
14211419
case idx =>
14221420
val phasePart = str drop (idx + 1)
1423-
settings.Yshow.tryToSetColon(phasePart split ',' toList)
1421+
settings.Yshow.tryToSetColon(phasePart.split(',').toList)
14241422
mkName(str take idx)
14251423
}
14261424
}
@@ -1699,7 +1697,7 @@ class Global(var currentSettings: Settings, reporter0: LegacyReporter)
16991697
val syms = findMemberFromRoot(fullName) match {
17001698
// The name as given was not found, so we'll sift through every symbol in
17011699
// the run looking for plausible matches.
1702-
case NoSymbol => phased(currentRun.symSource.keys map (sym => findNamedMember(fullName, sym)) filterNot (_ == NoSymbol) toList)
1700+
case NoSymbol => phased(currentRun.symSource.keys.map(findNamedMember(fullName, _)).filterNot(_ == NoSymbol).toList)
17031701
// The name as given matched, so show only that.
17041702
case sym => List(sym)
17051703
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
package scala.tools
1414
package nsc
1515

16-
import scala.language.postfixOps
17-
1816
/** The main class for NSC, a compiler for the programming
1917
* language Scala.
2018
*/
2119
class MainClass extends Driver with EvalLoop {
2220
def resident(compiler: Global): Unit = loop { line =>
23-
val command = new CompilerCommand(line split "\\s+" toList, new Settings(scalacError))
21+
val command = new CompilerCommand(line.split("\\s+").toList, new Settings(scalacError))
2422
compiler.reporter.reset()
2523
new compiler.Run() compile command.files
2624
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
package scala.tools.nsc
1414

1515
import scala.collection.mutable
16-
import scala.language.postfixOps
1716

1817
/** Converts an unordered morass of components into an order that
1918
* satisfies their mutual constraints.
@@ -99,7 +98,7 @@ trait PhaseAssembly {
9998
* names are sorted alphabetical at each level, into the compiler phase list
10099
*/
101100
def compilerPhaseList(): List[SubComponent] =
102-
nodes.values.toList filter (_.level > 0) sortBy (x => (x.level, x.phasename)) flatMap (_.phaseobj) flatten
101+
nodes.values.toList.filter(_.level > 0).sortBy(x => (x.level, x.phasename)).flatMap(_.phaseobj).flatten
103102

104103
/* Test if there are cycles in the graph, assign levels to the nodes
105104
* and collapse hard links into nodes

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package ast
1515

1616
import java.lang.System.{lineSeparator => EOL}
1717
import symtab.Flags._
18-
import scala.language.postfixOps
1918
import scala.reflect.internal.util.ListOfNil
2019

2120
/** The object `nodePrinter` converts the internal tree
@@ -67,8 +66,8 @@ abstract class NodePrinters {
6766
def showAttributes(tree: Tree): String = {
6867
if (infolevel == InfoLevel.Quiet) ""
6968
else {
70-
try { List(showSymbol(tree), showType(tree)) filterNot (_ == "") mkString ", " trim }
71-
catch { case ex: Throwable => "sym= <error> " + ex.getMessage }
69+
try List(showSymbol(tree), showType(tree)).filterNot(_ == "").mkString(", ").trim
70+
catch { case ex: Throwable => s"sym= <error> ${ex.getMessage}" }
7271
}
7372
}
7473
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ trait TreeDSL {
128128
}
129129
class TryStart(body: Tree, catches: List[CaseDef], fin: Tree) {
130130
def CATCH(xs: CaseDef*) = new TryStart(body, xs.toList, fin)
131-
def ENDTRY = Try(body, catches, fin)
131+
def FINALLY(end: END.type) = Try(body, catches, fin)
132+
def FINALLY(fin1: Tree) = Try(body, catches, fin1)
132133
}
134+
object END
133135

134136
def CASE(pat: Tree): CaseStart = new CaseStart(pat, EmptyTree)
135137
def DEFAULT: CaseStart = new CaseStart(Ident(nme.WILDCARD), EmptyTree)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package ast
1515

1616
import scala.collection.mutable.ListBuffer
1717
import symtab.Flags._
18-
import scala.language.postfixOps
1918
import scala.reflect.internal.util.FreshNameCreator
2019
import scala.reflect.internal.util.ListOfNil
2120

@@ -106,7 +105,7 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
106105
def mkAppliedTypeForCase(clazz: Symbol): Tree = {
107106
val numParams = clazz.typeParams.size
108107
if (clazz.typeParams.isEmpty) Ident(clazz)
109-
else AppliedTypeTree(Ident(clazz), 1 to numParams map (_ => Bind(tpnme.WILDCARD, EmptyTree)) toList)
108+
else AppliedTypeTree(Ident(clazz), (1 to numParams).map(_ => Bind(tpnme.WILDCARD, EmptyTree)).toList)
110109
}
111110
def mkBindForCase(patVar: Symbol, clazz: Symbol, targs: List[Type]): Tree = {
112111
Bind(patVar, Typed(Ident(nme.WILDCARD),

src/compiler/scala/tools/nsc/ast/parser/Scanners.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Tokens._
2020
import scala.annotation.{switch, tailrec}
2121
import scala.collection.mutable, mutable.{ListBuffer, ArrayBuffer}
2222
import scala.tools.nsc.ast.parser.xml.Utility.isNameStart
23-
import scala.language.postfixOps
2423

2524
/** See Parsers.scala / ParsersCommon for some explanation of ScannersCommon.
2625
*/
@@ -1379,7 +1378,7 @@ trait Scanners extends ScannersCommon {
13791378
/** The source code with braces and line starts annotated with [NN] showing the index */
13801379
private def markedSource = {
13811380
val code = unit.source.content
1382-
val braces = code.indices filter (idx => "{}\n" contains code(idx)) toSet
1381+
val braces = code.indices.filter(idx => "{}\n" contains code(idx)).toSet
13831382
val mapped = code.indices map (idx => if (braces(idx)) s"${code(idx)}[$idx]" else "" + code(idx))
13841383
mapped.mkString("")
13851384
}

src/compiler/scala/tools/nsc/io/Jar.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
package scala.tools.nsc
1414
package io
1515

16-
import scala.language.postfixOps
1716
import java.io.{DataOutputStream, InputStream, OutputStream}
1817
import java.util.jar._
1918

@@ -51,9 +50,9 @@ class Jar(file: File) extends AbstractIterable[JarEntry] {
5150
def mainClass = manifest map (f => f(Name.MAIN_CLASS))
5251
/** The manifest-defined classpath String if available. */
5352
def classPathString: Option[String] =
54-
for (m <- manifest ; cp <- m.attrs get Name.CLASS_PATH) yield cp
53+
for (m <- manifest ; cp <- m.attrs.get(Name.CLASS_PATH)) yield cp
5554
def classPathElements: List[String] = classPathString match {
56-
case Some(s) => s split "\\s+" toList
55+
case Some(s) => s.split("\\s+").toList
5756
case _ => Nil
5857
}
5958

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package scala.tools.nsc
1414
package symtab
1515

1616
import scala.language.implicitConversions
17-
import scala.language.postfixOps
1817

1918
/** Printing the symbol graph (for those symbols attached to an AST node)
2019
* after each phase.
@@ -176,8 +175,8 @@ trait SymbolTrackers {
176175
val change = Change(added, removed, prevMap, owners, flags)
177176

178177
prevMap = currentMap
179-
prevOwners = current map (s => (s, s.owner)) toMap;
180-
prevFlags = current map (s => (s, (s.flags & flagsMask))) toMap;
178+
prevOwners = current.map(s => (s, s.owner)).toMap
179+
prevFlags = current.map(s => (s, (s.flags & flagsMask))).toMap
181180
history = change :: history
182181
}
183182
def show(label: String): String = {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package transform
1616
import symtab._
1717
import Flags._
1818
import scala.collection._
19-
import scala.language.postfixOps
2019

2120
abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
2221
import global._
@@ -269,7 +268,7 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL {
269268
def catchBody = Throw(Apply(Select(Ident(invokeExc), nme.getCause), Nil))
270269

271270
// try { method.invoke } catch { case e: InvocationTargetExceptionClass => throw e.getCause() }
272-
fixResult(TRY (invocation) CATCH { CASE (catchVar) ==> catchBody } ENDTRY)
271+
fixResult(TRY (invocation) CATCH { CASE (catchVar) ==> catchBody } FINALLY END)
273272
}
274273

275274
/* A possible primitive method call, represented by methods in BoxesRunTime. */

src/compiler/scala/tools/nsc/typechecker/Checkable.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package scala.tools.nsc
1414
package typechecker
1515

1616
import Checkability._
17-
import scala.language.postfixOps
1817

1918
/** On pattern matcher checkability:
2019
*
@@ -292,7 +291,7 @@ trait Checkable {
292291
case TypeRef(_, NothingClass | NullClass | AnyValClass, _) => false
293292
case RefinedType(_, decls) if !decls.isEmpty => false
294293
case RefinedType(parents, _) => parents forall isCheckable
295-
case p => new CheckabilityChecker(AnyTpe, p) isCheckable
294+
case p => new CheckabilityChecker(AnyTpe, p).isCheckable
296295
})
297296
)
298297

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package typechecker
1616
import scala.annotation.tailrec
1717
import scala.collection.mutable
1818
import symtab.Flags._
19-
import scala.language.postfixOps
2019
import scala.reflect.internal.util.ListOfNil
2120

2221
/** This trait declares methods to create symbols and to enter them into scopes.
@@ -1203,7 +1202,7 @@ trait Namers extends MethodSynthesis {
12031202
val modClass = companionSymbolOf(clazz, context).moduleClass
12041203
modClass.attachments.get[ClassForCaseCompanionAttachment] foreach { cma =>
12051204
val cdef = cma.caseClass
1206-
def hasCopy = (decls containsName nme.copy) || parents.exists(_ member nme.copy exists)
1205+
def hasCopy = (decls containsName nme.copy) || parents.exists(_.member(nme.copy).exists)
12071206

12081207
// scala/bug#5956 needs (cdef.symbol == clazz): there can be multiple class symbols with the same name
12091208
if (cdef.symbol == clazz && !hasCopy)

src/compiler/scala/tools/nsc/typechecker/RefChecks.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
package scala.tools.nsc
1414
package typechecker
1515

16-
import scala.language.postfixOps
17-
1816
import scala.collection.mutable
1917
import scala.collection.mutable.ListBuffer
2018
import scala.tools.nsc.settings.ScalaVersion
@@ -23,7 +21,6 @@ import scala.tools.nsc.settings.NoScalaVersion
2321
import symtab.Flags._
2422
import transform.Transform
2523

26-
2724
/** <p>
2825
* Post-attribution checking and transformation.
2926
* </p>
@@ -1038,7 +1035,7 @@ abstract class RefChecks extends Transform {
10381035
def isMaybeAnyValue(s: Symbol) = isPrimitiveValueClass(unboxedValueClass(s)) || isMaybeValue(s)
10391036
// used to short-circuit unrelatedTypes check if both sides are special
10401037
def isSpecial(s: Symbol) = isMaybeAnyValue(s) || isAnyNumber(s)
1041-
val nullCount = onSyms(_ filter (_ == NullClass) size)
1038+
val nullCount = onSyms(_.filter(_ == NullClass).size)
10421039
def isNonsenseValueClassCompare = (
10431040
!haveSubclassRelationship
10441041
&& isUsingDefaultScalaOp

src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
package scala.tools.nsc
1414
package typechecker
1515

16-
import scala.language.postfixOps
17-
1816
import scala.collection.mutable
1917
import scala.collection.mutable.ListBuffer
2018

@@ -71,7 +69,7 @@ trait SyntheticMethods extends ast.TreeDSL {
7169
*/
7270
def addSyntheticMethods(templ: Template, clazz0: Symbol, context: Context): Template = {
7371
val syntheticsOk = (phase.id <= currentRun.typerPhase.id) && {
74-
symbolsToSynthesize(clazz0) filter (_ matchingSymbol clazz0.info isSynthetic) match {
72+
symbolsToSynthesize(clazz0).filter(_.matchingSymbol(clazz0.info).isSynthetic) match {
7573
case Nil => true
7674
case syms => log("Not adding synthetic methods: already has " + syms.mkString(", ")) ; false
7775
}

src/compiler/scala/tools/util/VerifyClass.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package scala.tools.util
1515
import scala.tools.nsc.io._
1616
import java.net.URLClassLoader
1717
import scala.collection.JavaConverters._
18-
import scala.language.postfixOps
1918

2019
object VerifyClass {
2120

@@ -30,14 +29,14 @@ object VerifyClass {
3029
}
3130
}
3231

33-
def checkClassesInJar(name: String, cl: ClassLoader) = new Jar(File(name)) filter (_.getName.endsWith(".class")) map { x =>
32+
def checkClassesInJar(name: String, cl: ClassLoader) = new Jar(File(name)).filter(_.getName.endsWith(".class")).map { x =>
3433
checkClass(x.getName.stripSuffix(".class").replace('/', '.'), cl)
35-
} toMap
34+
}.toMap
3635

3736
def checkClassesInDir(name: String, cl: ClassLoader) = (for {
3837
file <- Path(name).walk
3938
if file.name endsWith ".class"
40-
} yield checkClass(name, cl)) toMap
39+
} yield checkClass(name, cl)).toMap
4140

4241
def checkClasses(name: String, cl: ClassLoader) =
4342
if (name endsWith ".jar") checkClassesInJar(name, cl)

0 commit comments

Comments
 (0)