Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a0c370a

Browse files
authored
Merge pull request #6994 from dotty-staging/drop-do-while
Drop do while
2 parents e22ed0b + 46d2324 commit a0c370a

File tree

41 files changed

+145
-120
lines changed

Some content is hidden

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

41 files changed

+145
-120
lines changed

‎compiler/src/dotty/tools/backend/jvm/BTypes.scala‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,15 @@ abstract class BTypes {
719719
var chainA = as
720720
var chainB = bs
721721
var fcs: ClassBType = null
722-
do {
722+
while {
723723
if (chainB contains chainA.head) fcs = chainA.head
724724
else if (chainA contains chainB.head) fcs = chainB.head
725725
else {
726726
chainA = chainA.tail
727727
chainB = chainB.tail
728728
}
729-
} while (fcs == null)
729+
fcs == null
730+
} do ()
730731
fcs
731732
}
732733

‎compiler/src/dotty/tools/dotc/ast/Desugar.scala‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,10 +1569,6 @@ object desugar {
15691569
case PrefixOp(op, t) =>
15701570
val nspace = if (ctx.mode.is(Mode.Type)) tpnme else nme
15711571
Select(t, nspace.UNARY_PREFIX ++ op.name)
1572-
case DoWhile(body, cond) =>
1573-
// while ({ { body }; { cond } }) { () }
1574-
// the inner blocks are there to protect the scopes of body and cond from each other
1575-
WhileDo(Block(Block(Nil, body), Block(Nil, cond)), Literal(Constant(())))
15761572
case ForDo(enums, body) =>
15771573
makeFor(nme.foreach, nme.foreach, enums, body) orElse tree
15781574
case ForYield(enums, body) =>

‎compiler/src/dotty/tools/dotc/ast/untpd.scala‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
102102
case class Quote(quoted: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
103103
case class Splice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
104104
case class TypSplice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TypTree
105-
case class DoWhile(body: Tree, cond: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
106105
case class ForYield(enums: List[Tree], expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
107106
case class ForDo(enums: List[Tree], body: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
108107
case class GenFrom(pat: Tree, expr: Tree, checkMode: GenCheckMode)(implicit @constructorOnly src: SourceFile) extends Tree
@@ -532,10 +531,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
532531
case tree: TypSplice if expr eq tree.expr => tree
533532
case _ => finalize(tree, untpd.TypSplice(expr)(tree.source))
534533
}
535-
def DoWhile(tree: Tree)(body: Tree, cond: Tree)(implicit ctx: Context): TermTree = tree match {
536-
case tree: DoWhile if (body eq tree.body) && (cond eq tree.cond) => tree
537-
case _ => finalize(tree, untpd.DoWhile(body, cond)(tree.source))
538-
}
539534
def ForYield(tree: Tree)(enums: List[Tree], expr: Tree)(implicit ctx: Context): TermTree = tree match {
540535
case tree: ForYield if (enums eq tree.enums) && (expr eq tree.expr) => tree
541536
case _ => finalize(tree, untpd.ForYield(enums, expr)(tree.source))
@@ -604,8 +599,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
604599
cpy.Splice(tree)(transform(expr))
605600
case TypSplice(expr) =>
606601
cpy.TypSplice(tree)(transform(expr))
607-
case DoWhile(body, cond) =>
608-
cpy.DoWhile(tree)(transform(body), transform(cond))
609602
case ForYield(enums, expr) =>
610603
cpy.ForYield(tree)(transform(enums), transform(expr))
611604
case ForDo(enums, body) =>
@@ -661,8 +654,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
661654
this(x, expr)
662655
case TypSplice(expr) =>
663656
this(x, expr)
664-
case DoWhile(body, cond) =>
665-
this(this(x, body), cond)
666657
case ForYield(enums, expr) =>
667658
this(this(x, enums), expr)
668659
case ForDo(enums, body) =>

‎compiler/src/dotty/tools/dotc/core/Denotations.scala‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,11 @@ object Denotations {
802802
def history: List[SingleDenotation] = {
803803
val b = new ListBuffer[SingleDenotation]
804804
var current = initial
805-
do {
805+
while {
806806
b += (current)
807807
current = current.nextInRun
808-
}
809-
while (current ne initial)
808+
current ne initial
809+
} do ()
810810
b.toList
811811
}
812812

@@ -820,11 +820,12 @@ object Denotations {
820820
symbol.is(Permanent), // Permanent symbols are valid in all runIds
821821
s"denotation $this invalid in run ${ctx.runId}. ValidFor: $validFor")
822822
var d: SingleDenotation = this
823-
do {
823+
while {
824824
d.validFor = Period(ctx.period.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId)
825825
d.invalidateInheritedInfo()
826826
d = d.nextInRun
827-
} while (d ne this)
827+
d ne this
828+
} do ()
828829
this
829830
}
830831

@@ -1053,12 +1054,13 @@ object Denotations {
10531054
var cur = this
10541055
var cnt = 0
10551056
var interval = validFor
1056-
do {
1057+
while {
10571058
cur = cur.nextInRun
10581059
cnt += 1
10591060
assert(cnt <= MaxPossiblePhaseId, demandOutsideDefinedMsg)
10601061
interval |= cur.validFor
1061-
} while (cur ne this)
1062+
cur ne this
1063+
} do ()
10621064
interval
10631065
}
10641066

@@ -1075,12 +1077,13 @@ object Denotations {
10751077
var sb = new StringBuilder()
10761078
var cur = this
10771079
var cnt = 0
1078-
do {
1080+
while {
10791081
sb.append(" " + cur.validFor)
10801082
cur = cur.nextInRun
10811083
cnt += 1
10821084
if (cnt > MaxPossiblePhaseId) { sb.append(" ..."); cur = this }
1083-
} while (cur ne this)
1085+
cur ne this
1086+
} do ()
10841087
sb.toString
10851088
}
10861089

‎compiler/src/dotty/tools/dotc/core/Scopes.scala‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ object Scopes {
382382
override final def lookupNextEntry(entry: ScopeEntry)(implicit ctx: Context): ScopeEntry = {
383383
var e = entry
384384
if (hashTable ne null)
385-
do{ e = e.tail } while ((e ne null) && e.name != entry.name)
385+
while ({ e = e.tail ; (e ne null) && e.name != entry.name }) ()
386386
else
387-
do{ e = e.prev } while ((e ne null) && e.name != entry.name)
387+
while ({ e = e.prev ; (e ne null) && e.name != entry.name }) ()
388388
e
389389
}
390390

‎compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ class TastyBuffer(initialSize: Int) {
149149
var b = 0L
150150
var x = 0L
151151
var idx = at.index
152-
do {
152+
while {
153153
b = bytes(idx)
154154
x = (x << 7) | (b & 0x7f)
155155
idx += 1
156-
} while ((b & 0x80) == 0)
156+
(b & 0x80) == 0
157+
} do ()
157158
x
158159
}
159160

‎compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base: Int =
7575
def readLongNat(): Long = {
7676
var b = 0L
7777
var x = 0L
78-
do {
78+
while {
7979
b = bytes(bp)
8080
x = (x << 7) | (b & 0x7f)
8181
bp += 1
82-
} while ((b & 0x80) == 0)
82+
(b & 0x80) == 0
83+
} do ()
8384
x
8485
}
8586

‎compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ class TreeBuffer extends TastyBuffer(50000) {
175175
//println(s"offsets: ${offsets.take(numOffsets).deep}")
176176
//println(s"deltas: ${delta.take(numOffsets).deep}")
177177
var saved = 0
178-
do {
178+
while {
179179
saved = adjustDeltas()
180180
pickling.println(s"adjusting deltas, saved = $saved")
181-
} while (saved > 0 && length / saved < 100)
181+
saved > 0 && length / saved < 100
182+
} do ()
182183
adjustOffsets()
183184
adjustTreeAddrs()
184185
val wasted = compress()

‎compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
107107
def readLongNat(): Long = {
108108
var b = 0L
109109
var x = 0L
110-
do{
110+
while ({
111111
b = readByte()
112112
x = (x << 7) + (b & 0x7f)
113-
} while ((b & 0x80) != 0L)
113+
(b & 0x80) != 0L
114+
}) ()
114115
x
115116
}
116117

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /