Skip to content

Commit baac46c

Browse files
authored
chore: fix parameterless calls to functions (#23204)
Changes to parameterless/empty parameter list such that the code follows the specification. NOTE: This code shouldn't have compiled in the first place. I'm raising an issue as soon as I finish what I'm focusing on.
2 parents 13077f7 + 8fa6145 commit baac46c

19 files changed

+26
-26
lines changed

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ object MainGenericRunner {
158158
.withScriptArgs(tail*)
159159
.noSave // -save not useful here
160160
case arg :: tail =>
161-
val line = Try(Source.fromFile(arg).getLines.toList).toOption.flatMap(_.headOption)
161+
val line = Try(Source.fromFile(arg).getLines().toList).toOption.flatMap(_.headOption)
162162
lazy val hasScalaHashbang = { val s = line.getOrElse("") ; s.startsWith("#!") && s.contains("scala") }
163163
if arg.endsWith(".scala") || arg.endsWith(".sc") || hasScalaHashbang then
164164
settings

compiler/src/dotty/tools/dotc/cc/root.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ object root:
348348
val it = seen.iterator
349349
var ref: CaptureRef | Null = null
350350
while it.hasNext && ref == null do
351-
val (k, v) = it.next
351+
val (k, v) = it.next()
352352
if v.annot eq t.annot then ref = k
353353
if ref == null then
354354
ref = Fresh(Origin.Unknown)

compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ case class VirtualDirectoryClassPath(dir: VirtualDirectory) extends ClassPath wi
1515
var file: AbstractFile | Null = base
1616
val dirParts = pathParts.init.iterator
1717
while (dirParts.hasNext) {
18-
val dirPart = dirParts.next
18+
val dirPart = dirParts.next()
1919
file = file.lookupName(dirPart, directory = true)
2020
if (file == null)
2121
return null

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ object Contexts {
135135
def outersIterator: Iterator[Context] = new Iterator[Context] {
136136
var current = thiscontext
137137
def hasNext = current != NoContext
138-
def next = { val c = current; current = current.outer; c }
138+
def next() = { val c = current; current = current.outer; c }
139139
}
140140

141141
def period: Period

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ object SymDenotations {
11411141
final def ownersIterator(using Context): Iterator[Symbol] = new Iterator[Symbol] {
11421142
private var current = symbol
11431143
def hasNext = current.exists
1144-
def next: Symbol = {
1144+
def next(): Symbol = {
11451145
val result = current
11461146
current = current.owner
11471147
result
@@ -1418,7 +1418,7 @@ object SymDenotations {
14181418
final def nextOverriddenSymbol(using Context): Symbol = {
14191419
val overridden = allOverriddenSymbols
14201420
if (overridden.hasNext)
1421-
overridden.next
1421+
overridden.next()
14221422
else
14231423
NoSymbol
14241424
}
@@ -1496,10 +1496,10 @@ object SymDenotations {
14961496
val candidates = owner.info.decls.lookupAll(name)
14971497
def test(sym: Symbol): Symbol =
14981498
if (sym == symbol || sym.signature == signature) sym
1499-
else if (candidates.hasNext) test(candidates.next)
1499+
else if (candidates.hasNext) test(candidates.next())
15001500
else NoSymbol
15011501
if (candidates.hasNext) {
1502-
val sym = candidates.next
1502+
val sym = candidates.next()
15031503
if (candidates.hasNext) test(sym) else sym
15041504
}
15051505
else NoSymbol

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ object Types extends TypeUtils {
16301630
def underlyingIterator(using Context): Iterator[Type] = new Iterator[Type] {
16311631
var current = Type.this
16321632
var hasNext = true
1633-
def next = {
1633+
def next() = {
16341634
val res = current
16351635
hasNext = current.isInstanceOf[TypeProxy]
16361636
if (hasNext) current = current.asInstanceOf[TypeProxy].underlying

compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ object TastyPrinter:
6060
else if arg.endsWith(".jar") then
6161
val jar = JarArchive.open(Path(arg), create = false)
6262
try
63-
for file <- jar.iterator() if file.hasTastyExtension do
63+
for file <- jar.iterator if file.hasTastyExtension do
6464
printTasty(s"$arg ${file.path}", file.toByteArray, isBestEffortTasty = false)
6565
finally jar.close()
6666
else
@@ -123,7 +123,7 @@ class TastyPrinter(bytes: Array[Byte], isBestEffortTasty: Boolean, val testPickl
123123
unpickle0(new PositionSectionUnpickler(sb))
124124
unpickle0(new CommentSectionUnpickler(sb))
125125
unpickle0(new AttributesSectionUnpickler(sb))
126-
sb.result
126+
sb.result()
127127
}
128128

129129
def unpickle0[R](sec: PrinterSectionUnpickler[R])(using NameRefs): Option[R] =
@@ -266,7 +266,7 @@ class TastyPrinter(bytes: Array[Byte], isBestEffortTasty: Boolean, val testPickl
266266
val value = nameAtRef(utf8Ref).toString
267267
sb.append(nameStr(s" ${utf8Ref.index} [$value]"))
268268
sb.append("\n")
269-
sb.result
269+
sb.result()
270270
}
271271
}
272272

@@ -295,7 +295,7 @@ class TastyPrinter(bytes: Array[Byte], isBestEffortTasty: Boolean, val testPickl
295295
for ((_, nameRef) <- sources.iterator) {
296296
buf += nameRef
297297
}
298-
NameRefs(buf.result)
298+
NameRefs(buf.result())
299299
}
300300
}
301301

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) {
958958
val it = mp.keysIterator
959959
var i = 0
960960
while i < keys.length do
961-
keys(i) = it.next
961+
keys(i) = it.next()
962962
i += 1
963963
assert(!it.hasNext)
964964
i = 0

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class Inliner(val call: tpd.Tree)(using Context):
683683
// call. This way, a defensively written rewrite method can always
684684
// report bad inputs at the point of call instead of revealing its internals.
685685
val callToReport = if (enclosingInlineds.nonEmpty) enclosingInlineds.last else call
686-
val ctxToReport = ctx.outersIterator.dropWhile(enclosingInlineds(using _).nonEmpty).next
686+
val ctxToReport = ctx.outersIterator.dropWhile(enclosingInlineds(using _).nonEmpty).next()
687687
// The context in which we report should still use the existing context reporter
688688
val ctxOrigReporter = ctxToReport.fresh.setReporter(ctx.reporter)
689689
inContext(ctxOrigReporter) {

compiler/src/dotty/tools/dotc/transform/Mixin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
250250
case Some((_, _, args)) => args.iterator
251251
case _ => Iterator.empty
252252
def nextArgument() =
253-
if argsIt.hasNext then argsIt.next
253+
if argsIt.hasNext then argsIt.next()
254254
else
255255
assert(
256256
impl.parents.forall(_.tpe.typeSymbol != mixin),

compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class PickleQuotes extends MacroTransform {
139139

140140
/** Get the holeContents of the transformed tree */
141141
def getContents() =
142-
val res = holeContents.result
142+
val res = holeContents.result()
143143
holeContents.clear()
144144
res
145145
end HoleContentExtractor

compiler/src/dotty/tools/io/AbstractFile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ abstract class AbstractFile extends Iterable[AbstractFile] {
196196
}
197197

198198
/** Returns all abstract subfiles of this abstract directory. */
199-
def iterator(): Iterator[AbstractFile]
199+
def iterator: Iterator[AbstractFile]
200200

201201
/** Drill down through subdirs looking for the target, as in lookupName.
202202
* Ths target name is the last of parts.

compiler/src/dotty/tools/io/PlainFile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.nio.file.{InvalidPathException, Paths}
1414
/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
1515
class PlainDirectory(givenPath: Directory) extends PlainFile(givenPath) {
1616
override val isDirectory: Boolean = true
17-
override def iterator(): Iterator[PlainFile] = givenPath.list.filter(_.exists).map(new PlainFile(_))
17+
override def iterator: Iterator[PlainFile] = givenPath.list.filter(_.exists).map(new PlainFile(_))
1818
}
1919

2020
/** This class implements an abstract file backed by a File.

compiler/src/dotty/tools/io/VirtualDirectory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extends AbstractFile {
4343

4444
// the toList is so that the directory may continue to be
4545
// modified while its elements are iterated
46-
def iterator(): Iterator[AbstractFile] = files.values.toList.iterator
46+
def iterator: Iterator[AbstractFile] = files.values.toList.iterator
4747

4848
override def lookupName(name: String, directory: Boolean): AbstractFile =
4949
(files get name filter (_.isDirectory == directory)).orNull

compiler/src/dotty/tools/io/ZipArchive.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ final class FileZipArchive(jpath: JPath, release: Option[String]) extends ZipArc
220220
}
221221

222222
final class ManifestResources(val url: URL) extends ZipArchive(null, None) {
223-
def iterator(): Iterator[AbstractFile] = {
223+
def iterator: Iterator[AbstractFile] = {
224224
val root = new DirEntry("/", null)
225225
val dirs = mutable.HashMap[String, DirEntry]("/" -> root)
226226
val stream = input

compiler/test/dotty/tools/dotc/SettingsTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class SettingsTests {
245245
assertNotEquals(file1StateBefore, String(Files.readAllBytes(file1)))
246246
assertEquals(file2StateBefore, String(Files.readAllBytes(file2)))
247247

248-
}(Files.deleteIfExists(_), Files.deleteIfExists(_))
248+
}(using Files.deleteIfExists(_), Files.deleteIfExists(_))
249249

250250
@Test def `Output side effect is not present when setting is deprecated`: Unit =
251251
val result = Using.resource(Files.createTempFile("myfile", ".jar")){ file =>

compiler/test/dotty/tools/dotc/core/tasty/PathPicklingTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PathPicklingTest {
4747
val sb = new StringBuffer
4848
val jar = JarArchive.open(Path(s"$out/out.jar"), create = false)
4949
try
50-
for file <- jar.iterator() if file.name.endsWith(".tasty") do
50+
for file <- jar.iterator if file.name.endsWith(".tasty") do
5151
sb.append(TastyPrinter.showContents(file.toByteArray, noColor = true, isBestEffortTasty = false))
5252
finally jar.close()
5353
sb.toString()

compiler/test/dotty/tools/utils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension (str: String) def dropExtension =
4141

4242
private
4343
def withFile[T](file: File)(action: Source => T): T = resource(Source.fromFile(file, UTF_8.name))(action)
44-
def readLines(f: File): List[String] = withFile(f)(_.getLines.toList)
44+
def readLines(f: File): List[String] = withFile(f)(_.getLines().toList)
4545
def readFile(f: File): String = withFile(f)(_.mkString)
4646

4747
private object Unthrown extends ControlThrowable

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
838838
count += 1
839839
for file <- files if isSourceFile(file) do
840840
Using.resource(Source.fromFile(file, StandardCharsets.UTF_8.name)) { source =>
841-
source.getLines.zipWithIndex.foreach: (line, lineNbr) =>
841+
source.getLines().zipWithIndex.foreach: (line, lineNbr) =>
842842
comment.findAllMatchIn(line).foreach:
843843
case comment("nopos-") => bump("nopos")
844844
case _ => bump(s"${file.getPath}:${lineNbr+1}")
@@ -980,7 +980,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
980980
expectedErrors += 1
981981
files.filter(isSourceFile).foreach { file =>
982982
Using(Source.fromFile(file, StandardCharsets.UTF_8.name)) { source =>
983-
source.getLines.zipWithIndex.foreach { case (line, lineNbr) =>
983+
source.getLines().zipWithIndex.foreach { case (line, lineNbr) =>
984984
comment.findAllMatchIn(line).foreach { m =>
985985
m.group(2) match
986986
case prefix if m.group(1).isEmpty =>

0 commit comments

Comments
 (0)