Skip to content

Commit e2094bf

Browse files
authored
Merge pull request #6620 from lrytz/strawman520
Remove () from iterator
2 parents 6fcad4d + 1587fd6 commit e2094bf

File tree

139 files changed

+696
-696
lines changed

Some content is hidden

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

139 files changed

+696
-696
lines changed

src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ object AsmUtils {
161161
/**
162162
* Returns a human-readable representation of the given instruction sequence.
163163
*/
164-
def textify(insns: InsnList): String = textify(insns.iterator().asScala)
164+
def textify(insns: InsnList): String = textify(insns.iterator.asScala)
165165

166166
/**
167167
* Run ASM's CheckClassAdapter over a class. Returns None if no problem is found, otherwise

src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ abstract class BCodeIdiomatic {
667667
implicit class InsnIterInsnList(lst: asm.tree.InsnList) {
668668

669669
@inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit): Unit = {
670-
val insnIter = lst.iterator()
670+
val insnIter = lst.iterator
671671
while (insnIter.hasNext) {
672672
f(insnIter.next())
673673
}

src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ abstract class BackendUtils extends PerRunInit {
476476
}
477477
}
478478

479-
val tcbIt = method.tryCatchBlocks.iterator()
479+
val tcbIt = method.tryCatchBlocks.iterator
480480
while (tcbIt.hasNext) {
481481
val tcb = tcbIt.next()
482482
enqInsn(tcb.handler, 1)
@@ -641,7 +641,7 @@ object BackendUtils {
641641
m.exceptions.asScala foreach visitInternalName
642642
for (tcb <- m.tryCatchBlocks.asScala) visitInternalName(tcb.`type`)
643643

644-
val iter = m.instructions.iterator()
644+
val iter = m.instructions.iterator
645645
while (iter.hasNext) iter.next() match {
646646
case ti: TypeInsnNode => visitInternalNameOrArrayReference(ti.desc)
647647
case fi: FieldInsnNode => visitInternalNameOrArrayReference(fi.owner); visitDescriptor(fi.desc)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,15 @@ object BytecodeUtils {
294294
}
295295

296296
def removeLineNumberNodes(instructions: InsnList): Unit = {
297-
val iter = instructions.iterator()
297+
val iter = instructions.iterator
298298
while (iter.hasNext) iter.next() match {
299299
case _: LineNumberNode => iter.remove()
300300
case _ =>
301301
}
302302
}
303303

304304
def cloneLabels(methodNode: MethodNode): Map[LabelNode, LabelNode] = {
305-
methodNode.instructions.iterator().asScala.collect({
305+
methodNode.instructions.iterator.asScala.collect({
306306
case labelNode: LabelNode => (labelNode, newLabelNode)
307307
}).toMap
308308
}
@@ -322,7 +322,7 @@ object BytecodeUtils {
322322
* according to the `labelMap`.
323323
*/
324324
def cloneLocalVariableNodes(methodNode: MethodNode, labelMap: Map[LabelNode, LabelNode], calleeMethodName: String, shift: Int): List[LocalVariableNode] = {
325-
methodNode.localVariables.iterator().asScala.map(localVariable => {
325+
methodNode.localVariables.iterator.asScala.map(localVariable => {
326326
val name =
327327
if (calleeMethodName.length + localVariable.name.length < BTypes.InlinedLocalVariablePrefixMaxLength) {
328328
calleeMethodName + "_" + localVariable.name
@@ -355,7 +355,7 @@ object BytecodeUtils {
355355
* labels according to the `labelMap`.
356356
*/
357357
def cloneTryCatchBlockNodes(methodNode: MethodNode, labelMap: Map[LabelNode, LabelNode]): List[TryCatchBlockNode] = {
358-
methodNode.tryCatchBlocks.iterator().asScala.map(tryCatch => new TryCatchBlockNode(
358+
methodNode.tryCatchBlocks.iterator.asScala.map(tryCatch => new TryCatchBlockNode(
359359
labelMap(tryCatch.start),
360360
labelMap(tryCatch.end),
361361
labelMap(tryCatch.handler),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ abstract class Inliner {
482482
// large methods are not added to the call graph.
483483
val analyzer = new AsmAnalyzer(callee, calleeDeclarationClass.internalName)
484484

485-
for (originalReturn <- callee.instructions.iterator().asScala if isReturn(originalReturn)) {
485+
for (originalReturn <- callee.instructions.iterator.asScala if isReturn(originalReturn)) {
486486
val frame = analyzer.frameAt(originalReturn)
487487
var stackHeight = frame.getStackSize
488488

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ abstract class LocalOpt {
425425
// cannot change instructions while iterating, it gets the analysis out of synch (indexed by instructions)
426426
val toReplace = mutable.Map.empty[AbstractInsnNode, List[AbstractInsnNode]]
427427

428-
val it = method.instructions.iterator()
428+
val it = method.instructions.iterator
429429
while (it.hasNext) it.next() match {
430430
case vi: VarInsnNode if isNull(vi, vi.`var`) =>
431431
if (vi.getOpcode == ALOAD)
@@ -506,7 +506,7 @@ abstract class LocalOpt {
506506
var changed = false
507507
var maxLocals = parametersSize(method)
508508
var maxStack = 0
509-
val itr = method.instructions.iterator()
509+
val itr = method.instructions.iterator
510510
while (itr.hasNext) {
511511
val insn = itr.next()
512512
val isLive = frames(i) != null
@@ -568,7 +568,7 @@ abstract class LocalOpt {
568568
// cannot remove instructions while iterating, it gets the analysis out of synch (indexed by instructions)
569569
val toRemove = mutable.Set.empty[TypeInsnNode]
570570

571-
val it = method.instructions.iterator()
571+
val it = method.instructions.iterator
572572
while (it.hasNext) it.next() match {
573573
case ti: TypeInsnNode if ti.getOpcode == CHECKCAST =>
574574
val frame = typeAnalyzer.frameAt(ti)
@@ -614,7 +614,7 @@ object LocalOptImpls {
614614

615615
var result: RemoveHandlersResult = RemoveHandlersResult.NoneRemoved
616616

617-
val handlersIter = method.tryCatchBlocks.iterator()
617+
val handlersIter = method.tryCatchBlocks.iterator
618618
while (handlersIter.hasNext) {
619619
val handler = handlersIter.next()
620620
if (!containsExecutableCode(handler.start, handler.end)) {
@@ -661,7 +661,7 @@ object LocalOptImpls {
661661
}
662662

663663
val initialNumVars = method.localVariables.size
664-
val localsIter = method.localVariables.iterator()
664+
val localsIter = method.localVariables.iterator
665665
while (localsIter.hasNext) {
666666
val local = localsIter.next()
667667
val index = local.index
@@ -707,7 +707,7 @@ object LocalOptImpls {
707707

708708
val firstLocalIndex = parametersSize(method)
709709
for (i <- 0 until firstLocalIndex) renumber += i // parameters and `this` are always used.
710-
method.instructions.iterator().asScala foreach {
710+
method.instructions.iterator.asScala foreach {
711711
case VarInstruction(varIns, slot) => addVar(varIns, slot)
712712
case _ =>
713713
}
@@ -728,7 +728,7 @@ object LocalOptImpls {
728728
else {
729729
// update variable instructions according to the renumber table
730730
method.maxLocals = nextIndex
731-
method.instructions.iterator().asScala.foreach {
731+
method.instructions.iterator.asScala.foreach {
732732
case VarInstruction(varIns, slot) =>
733733
val oldIndex = slot
734734
if (oldIndex >= firstLocalIndex && renumber(oldIndex) != oldIndex) varIns match {
@@ -759,7 +759,7 @@ object LocalOptImpls {
759759
}
760760

761761
val initialSize = method.instructions.size
762-
val iterator = method.instructions.iterator()
762+
val iterator = method.instructions.iterator
763763
var previousLabel: LabelNode = null
764764
while (iterator.hasNext) {
765765
iterator.next match {
@@ -788,7 +788,7 @@ object LocalOptImpls {
788788

789789
val jumpInsns = mutable.LinkedHashMap.empty[JumpInsnNode, Boolean]
790790

791-
for (insn <- method.instructions.iterator().asScala) insn match {
791+
for (insn <- method.instructions.iterator.asScala) insn match {
792792
case l: LabelNode =>
793793
activeHandlers ++= allHandlers.filter(_.start == l)
794794
activeHandlers = activeHandlers.filter(_.end != l)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No
176176

177177
// e.g. "java.lang" -> Seq("/modules/java.base")
178178
private val packageToModuleBases: Map[String, Seq[Path]] = {
179-
val ps = Files.newDirectoryStream(dir).iterator().asScala
179+
val ps = Files.newDirectoryStream(dir).iterator.asScala
180180
def lookup(pack: Path): Seq[Path] = {
181-
Files.list(pack).iterator().asScala.map(l => if (Files.isSymbolicLink(l)) Files.readSymbolicLink(l) else l).toList
181+
Files.list(pack).iterator.asScala.map(l => if (Files.isSymbolicLink(l)) Files.readSymbolicLink(l) else l).toList
182182
}
183183
ps.map(p => (p.toString.stripPrefix("/packages/"), lookup(p))).toMap
184184
}
@@ -192,7 +192,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No
192192
if (inPackage == "") Nil
193193
else {
194194
packageToModuleBases.getOrElse(inPackage, Nil).flatMap(x =>
195-
Files.list(x.resolve(inPackage.replace('.', '/'))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x =>
195+
Files.list(x.resolve(inPackage.replace('.', '/'))).iterator.asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x =>
196196
ClassFileEntryImpl(new PlainNioFile(x))).toVector
197197
}
198198
}
@@ -225,8 +225,8 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
225225
import java.nio.file.Path, java.nio.file._
226226

227227
private val fileSystem: FileSystem = FileSystems.newFileSystem(ctSym, null)
228-
private val root: Path = fileSystem.getRootDirectories.iterator().next
229-
private val roots = Files.newDirectoryStream(root).iterator().asScala.toList
228+
private val root: Path = fileSystem.getRootDirectories.iterator.next
229+
private val roots = Files.newDirectoryStream(root).iterator.asScala.toList
230230

231231
// http://mail.openjdk.java.net/pipermail/compiler-dev/2018-March/011737.html
232232
private def codeFor(major: Int): String = if (major < 10) major.toString else ('A' + (major - 10)).toChar.toString
@@ -238,7 +238,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
238238
// e.g. "java.lang" -> Seq(/876/java/lang, /87/java/lang, /8/java/lang))
239239
private val packageIndex: scala.collection.Map[String, scala.collection.Seq[Path]] = {
240240
val index = collection.mutable.AnyRefMap[String, collection.mutable.ListBuffer[Path]]()
241-
rootsForRelease.foreach(root => Files.walk(root).iterator().asScala.filter(Files.isDirectory(_)).foreach { p =>
241+
rootsForRelease.foreach(root => Files.walk(root).iterator.asScala.filter(Files.isDirectory(_)).foreach { p =>
242242
if (p.getNameCount > 1) {
243243
val packageDotted = p.subpath(1, p.getNameCount).toString.replace('/', '.')
244244
index.getOrElseUpdate(packageDotted, new collection.mutable.ListBuffer) += p
@@ -256,7 +256,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
256256
if (inPackage == "") Nil
257257
else {
258258
val sigFiles = packageIndex.getOrElse(inPackage, Nil).iterator.flatMap(p =>
259-
Files.list(p).iterator().asScala.filter(_.getFileName.toString.endsWith(".sig")))
259+
Files.list(p).iterator.asScala.filter(_.getFileName.toString.endsWith(".sig")))
260260
sigFiles.map(f => ClassFileEntryImpl(new PlainNioFile(f))).toVector
261261
}
262262
}

src/compiler/scala/tools/nsc/profile/Profiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private [profile] object RealProfiler {
8787
val threadMx = ExtendedThreadMxBean.proxy
8888
if (threadMx.isThreadCpuTimeSupported) threadMx.setThreadCpuTimeEnabled(true)
8989
private val idGen = new AtomicInteger()
90-
lazy val allPlugins = ServiceLoader.load(classOf[ProfilerPlugin]).iterator().asScala.toList
90+
lazy val allPlugins = ServiceLoader.load(classOf[ProfilerPlugin]).iterator.asScala.toList
9191
}
9292

9393
private [profile] class RealProfiler(reporter : ProfileReporter, val settings: Settings) extends Profiler with NotificationListener {

src/compiler/scala/tools/nsc/transform/patmat/Logic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ trait Logic extends Debugging {
357357

358358
val pure = props map (p => rewriteEqualsToProp(p))
359359

360-
val eqAxioms = ImmutableArray.newBuilder[Prop]()
360+
val eqAxioms = ImmutableArray.newBuilder[Prop]
361361
@inline def addAxiom(p: Prop) = eqAxioms += p
362362

363363
debug.patmat("removeVarEq vars: "+ vars)

src/compiler/scala/tools/nsc/transform/patmat/Solving.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ trait Solving extends Logic {
5757
val symForVar: Map[Int, Sym] = variableForSymbol.map(_.swap)
5858

5959
val relevantVars =
60-
symForVar.keysIterator().map(math.abs).to(immutable.BitSet)
60+
symForVar.keysIterator.map(math.abs).to(immutable.BitSet)
6161

6262
def lit(sym: Sym): Lit = Lit(variableForSymbol(sym))
6363

src/library/scala/Array.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ object Array {
4545
implicit def toFactory[A : ClassTag](dummy: Array.type): Factory[A, Array[A]] =
4646
new Factory[A, Array[A]] {
4747
def fromSpecific(it: IterableOnce[A]): Array[A] = Array.from[A](it)
48-
def newBuilder(): mutable.Builder[A, Array[A]] = Array.newBuilder[A]
48+
def newBuilder: mutable.Builder[A, Array[A]] = Array.newBuilder[A]
4949
}
5050

5151
/**
5252
* Returns a new [[scala.collection.mutable.ArrayBuilder]].
5353
*/
54-
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T]()(t)
54+
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T](t)
5555

5656
def from[A : ClassTag](it: IterableOnce[A]): Array[A] = {
5757
val n = it.knownSize
5858
if (n > -1) {
5959
val elements = new Array[A](n)
60-
val iterator = it.iterator()
60+
val iterator = it.iterator
6161
var i = 0
6262
while (i < n) {
6363
ScalaRunTime.array_update(elements, i, iterator.next())
6464
i = i + 1
6565
}
6666
elements
6767
} else {
68-
val b = ArrayBuilder.make[A]()
69-
val iterator = it.iterator()
68+
val b = ArrayBuilder.make[A]
69+
val iterator = it.iterator
7070
while (iterator.hasNext)
7171
b += iterator.next()
7272
b.result()

src/library/scala/Enumeration.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
288288
def toBitMask: Array[Long] = nnIds.toBitMask
289289

290290
override protected def fromSpecificIterable(coll: Iterable[Value]) = ValueSet.fromSpecific(coll)
291-
override protected def newSpecificBuilder() = ValueSet.newBuilder
291+
override protected def newSpecificBuilder = ValueSet.newBuilder
292292

293293
def map(f: Value => Value): ValueSet = fromSpecificIterable(new View.Map(toIterable, f))
294294
def flatMap(f: Value => IterableOnce[Value]): ValueSet = fromSpecificIterable(new View.FlatMap(toIterable, f))

0 commit comments

Comments
 (0)