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),

0 commit comments

Comments
 (0)