diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213
index 902738911796..9974ad627dff 160000
--- a/community-build/community-projects/stdLib213
+++ b/community-build/community-projects/stdLib213
@@ -1 +1 @@
-Subproject commit 902738911796d1bde386aeea100221112eb241cb
+Subproject commit 9974ad627dfffed04aca0e10d1603d90b55e67ee
diff --git a/compiler/src/dotty/tools/backend/jvm/BTypes.scala b/compiler/src/dotty/tools/backend/jvm/BTypes.scala
index 695ab8f253f0..071d9622ded2 100644
--- a/compiler/src/dotty/tools/backend/jvm/BTypes.scala
+++ b/compiler/src/dotty/tools/backend/jvm/BTypes.scala
@@ -719,14 +719,15 @@ abstract class BTypes {
var chainA = as
var chainB = bs
var fcs: ClassBType = null
- do {
+ while {
if (chainB contains chainA.head) fcs = chainA.head
else if (chainA contains chainB.head) fcs = chainB.head
else {
chainA = chainA.tail
chainB = chainB.tail
}
- } while (fcs == null)
+ fcs == null
+ } do ()
fcs
}
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala
index 17873cf62ecb..23e96d4bccbb 100644
--- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala
@@ -1569,10 +1569,6 @@ object desugar {
case PrefixOp(op, t) =>
val nspace = if (ctx.mode.is(Mode.Type)) tpnme else nme
Select(t, nspace.UNARY_PREFIX ++ op.name)
- case DoWhile(body, cond) =>
- // while ({ { body }; { cond } }) { () }
- // the inner blocks are there to protect the scopes of body and cond from each other
- WhileDo(Block(Block(Nil, body), Block(Nil, cond)), Literal(Constant(())))
case ForDo(enums, body) =>
makeFor(nme.foreach, nme.foreach, enums, body) orElse tree
case ForYield(enums, body) =>
diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala
index 3ccad3370b08..18f1920d4122 100644
--- a/compiler/src/dotty/tools/dotc/ast/untpd.scala
+++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala
@@ -102,7 +102,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
case class Quote(quoted: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
case class Splice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
case class TypSplice(expr: Tree)(implicit @constructorOnly src: SourceFile) extends TypTree
- case class DoWhile(body: Tree, cond: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
case class ForYield(enums: List[Tree], expr: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
case class ForDo(enums: List[Tree], body: Tree)(implicit @constructorOnly src: SourceFile) extends TermTree
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 {
case tree: TypSplice if expr eq tree.expr => tree
case _ => finalize(tree, untpd.TypSplice(expr)(tree.source))
}
- def DoWhile(tree: Tree)(body: Tree, cond: Tree)(implicit ctx: Context): TermTree = tree match {
- case tree: DoWhile if (body eq tree.body) && (cond eq tree.cond) => tree
- case _ => finalize(tree, untpd.DoWhile(body, cond)(tree.source))
- }
def ForYield(tree: Tree)(enums: List[Tree], expr: Tree)(implicit ctx: Context): TermTree = tree match {
case tree: ForYield if (enums eq tree.enums) && (expr eq tree.expr) => tree
case _ => finalize(tree, untpd.ForYield(enums, expr)(tree.source))
@@ -604,8 +599,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
cpy.Splice(tree)(transform(expr))
case TypSplice(expr) =>
cpy.TypSplice(tree)(transform(expr))
- case DoWhile(body, cond) =>
- cpy.DoWhile(tree)(transform(body), transform(cond))
case ForYield(enums, expr) =>
cpy.ForYield(tree)(transform(enums), transform(expr))
case ForDo(enums, body) =>
@@ -661,8 +654,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
this(x, expr)
case TypSplice(expr) =>
this(x, expr)
- case DoWhile(body, cond) =>
- this(this(x, body), cond)
case ForYield(enums, expr) =>
this(this(x, enums), expr)
case ForDo(enums, body) =>
diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala
index e15a4ba59025..4b0c3e415167 100644
--- a/compiler/src/dotty/tools/dotc/core/Denotations.scala
+++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala
@@ -802,11 +802,11 @@ object Denotations {
def history: List[SingleDenotation] = {
val b = new ListBuffer[SingleDenotation]
var current = initial
- do {
+ while {
b += (current)
current = current.nextInRun
- }
- while (current ne initial)
+ current ne initial
+ } do ()
b.toList
}
@@ -820,11 +820,12 @@ object Denotations {
symbol.is(Permanent), // Permanent symbols are valid in all runIds
s"denotation $this invalid in run ${ctx.runId}. ValidFor: $validFor")
var d: SingleDenotation = this
- do {
+ while {
d.validFor = Period(ctx.period.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId)
d.invalidateInheritedInfo()
d = d.nextInRun
- } while (d ne this)
+ d ne this
+ } do ()
this
}
@@ -1053,12 +1054,13 @@ object Denotations {
var cur = this
var cnt = 0
var interval = validFor
- do {
+ while {
cur = cur.nextInRun
cnt += 1
assert(cnt <= MaxPossiblePhaseId, demandOutsideDefinedMsg)
interval |= cur.validFor
- } while (cur ne this)
+ cur ne this
+ } do ()
interval
}
@@ -1075,12 +1077,13 @@ object Denotations {
var sb = new StringBuilder()
var cur = this
var cnt = 0
- do {
+ while {
sb.append(" " + cur.validFor)
cur = cur.nextInRun
cnt += 1
if (cnt > MaxPossiblePhaseId) { sb.append(" ..."); cur = this }
- } while (cur ne this)
+ cur ne this
+ } do ()
sb.toString
}
diff --git a/compiler/src/dotty/tools/dotc/core/Scopes.scala b/compiler/src/dotty/tools/dotc/core/Scopes.scala
index e00192938e17..f74d783dab34 100644
--- a/compiler/src/dotty/tools/dotc/core/Scopes.scala
+++ b/compiler/src/dotty/tools/dotc/core/Scopes.scala
@@ -382,9 +382,9 @@ object Scopes {
override final def lookupNextEntry(entry: ScopeEntry)(implicit ctx: Context): ScopeEntry = {
var e = entry
if (hashTable ne null)
- do { e = e.tail } while ((e ne null) && e.name != entry.name)
+ while ({ e = e.tail ; (e ne null) && e.name != entry.name }) ()
else
- do { e = e.prev } while ((e ne null) && e.name != entry.name)
+ while ({ e = e.prev ; (e ne null) && e.name != entry.name }) ()
e
}
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala
index 4e61f615aceb..d8a793715a08 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala
@@ -149,11 +149,12 @@ class TastyBuffer(initialSize: Int) {
var b = 0L
var x = 0L
var idx = at.index
- do {
+ while {
b = bytes(idx)
x = (x << 7) | (b & 0x7f)
idx += 1
- } while ((b & 0x80) == 0)
+ (b & 0x80) == 0
+ } do ()
x
}
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala
index 2c4dbc4b9247..f2defc3ffe51 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala
@@ -75,11 +75,12 @@ class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base: Int =
def readLongNat(): Long = {
var b = 0L
var x = 0L
- do {
+ while {
b = bytes(bp)
x = (x << 7) | (b & 0x7f)
bp += 1
- } while ((b & 0x80) == 0)
+ (b & 0x80) == 0
+ } do ()
x
}
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala
index 12ddbe163051..5bd1c48add8c 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala
@@ -175,10 +175,11 @@ class TreeBuffer extends TastyBuffer(50000) {
//println(s"offsets: ${offsets.take(numOffsets).deep}")
//println(s"deltas: ${delta.take(numOffsets).deep}")
var saved = 0
- do {
+ while {
saved = adjustDeltas()
pickling.println(s"adjusting deltas, saved = $saved")
- } while (saved > 0 && length / saved < 100)
+ saved > 0 && length / saved < 100
+ } do ()
adjustOffsets()
adjustTreeAddrs()
val wasted = compress()
diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala
index 78014fba2ce6..821501d79bef 100644
--- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala
+++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala
@@ -107,10 +107,11 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) {
def readLongNat(): Long = {
var b = 0L
var x = 0L
- do {
+ while ({
b = readByte()
x = (x << 7) + (b & 0x7f)
- } while ((b & 0x80) != 0L)
+ (b & 0x80) != 0L
+ }) ()
x
}
diff --git a/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala b/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala
index 14d7a53c0f0f..8e4d524dda8b 100644
--- a/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala
@@ -92,8 +92,10 @@ abstract class CharArrayReader { self =>
}
}
if (charOffset < buf.length && buf(charOffset) == 'u' && decodeUni && evenSlashPrefix) {
- do charOffset += 1
- while (charOffset < buf.length && buf(charOffset) == 'u')
+ while {
+ charOffset += 1
+ charOffset < buf.length && buf(charOffset) == 'u'
+ } do ()
val code = udigit << 12 | udigit << 8 | udigit << 4 | udigit
lastUnicodeOffset = charOffset
ch = code.toChar
diff --git a/compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala b/compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
index 71599dffc254..5e5cb394ebad 100644
--- a/compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala
@@ -141,7 +141,7 @@ object JavaParsers {
def skipAhead(): Unit = {
var nparens = 0
var nbraces = 0
- do {
+ while ({
in.token match {
case LPAREN =>
nparens += 1
@@ -157,7 +157,8 @@ object JavaParsers {
nbraces -= 1
case _ =>
}
- } while (in.token != EOF && (nparens > 0 || nbraces > 0))
+ in.token != EOF && (nparens > 0 || nbraces > 0)
+ }) ()
}
def skipTo(tokens: Int*): Unit = {
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index 28f7ac1f32fa..6306d2535e18 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -301,9 +301,6 @@ object Parsers {
def deprecationWarning(msg: => Message, offset: Int = in.offset): Unit =
ctx.deprecationWarning(msg, source.atSpan(Span(offset)))
- def errorOrMigrationWarning(msg: => Message, offset: Int = in.offset): Unit =
- ctx.errorOrMigrationWarning(msg, source.atSpan(Span(offset)))
-
/** Issue an error at current offset that input is incomplete */
def incompleteInputError(msg: => Message): Unit =
ctx.incompleteInputError(msg, source.atSpan(Span(in.offset)))
@@ -392,12 +389,6 @@ object Parsers {
finally staged = saved
}
- def migrationWarningOrError(msg: String, offset: Int = in.offset): Unit =
- if (in.isScala2Mode)
- ctx.migrationWarning(msg, source.atSpan(Span(offset)))
- else
- syntaxError(msg, offset)
-
/* ---------- TREE CONSTRUCTION ------------------------------------------- */
/** Convert tree to formal parameter list
@@ -780,9 +771,9 @@ object Parsers {
Quote(t)
}
else {
- migrationWarningOrError(em"""symbol literal '${in.name} is no longer supported,
- |use a string literal "${in.name}" or an application Symbol("${in.name}") instead,
- |or enclose in braces '{${in.name}} if you want a quoted expression.""")
+ in.errorOrMigrationWarning(em"""symbol literal '${in.name} is no longer supported,
+ |use a string literal "${in.name}" or an application Symbol("${in.name}") instead,
+ |or enclose in braces '{${in.name}} if you want a quoted expression.""")
if (in.isScala2Mode) {
patch(source, Span(in.offset, in.offset + 1), "Symbol(\"")
patch(source, Span(in.charOffset - 1), "\")")
@@ -1216,7 +1207,7 @@ object Parsers {
AppliedTypeTree(toplevelTyp(), Ident(pname))
} :: contextBounds(pname)
case VIEWBOUND =>
- errorOrMigrationWarning("view bounds `<%' are deprecated, use a context bound `:' instead")
+ in.errorOrMigrationWarning("view bounds `<%' are deprecated, use a context bound `:' instead")
atSpan(in.skipToken()) {
Function(Ident(pname) :: Nil, toplevelTyp())
} :: contextBounds(pname)
@@ -1339,12 +1330,30 @@ object Parsers {
WhileDo(cond, body)
}
case DO =>
- atSpan(in.skipToken()) {
+ in.errorOrMigrationWarning(
+ i"""`do
while ' is no longer supported,
+ |use `while { ; } do ()' instead.
+ |The statement can be rewritten automatically under -language:Scala2 -migration -rewrite.
+ """)
+ val start = in.skipToken()
+ atSpan(start) {
val body = expr()
if (isStatSep) in.nextToken()
+ val whileStart = in.offset
accept(WHILE)
val cond = expr()
- DoWhile(body, cond)
+ if (ctx.settings.migration.value) {
+ patch(source, Span(start, start + 2), "while ({")
+ patch(source, Span(whileStart, whileStart + 5), ";")
+ cond match {
+ case Parens(_) =>
+ patch(source, Span(cond.span.start, cond.span.start + 1), "")
+ patch(source, Span(cond.span.end - 1, cond.span.end), "")
+ case _ =>
+ }
+ patch(source, cond.span.endPos, "}) ()")
+ }
+ WhileDo(Block(body :: Nil, cond), Literal(Constant(())))
}
case TRY =>
val tryOffset = in.offset
@@ -1525,7 +1534,7 @@ object Parsers {
if (ctx.settings.strict.value)
// Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... "
// is not supported by Scala2.x
- migrationWarningOrError(s"This syntax is no longer supported; parameter needs to be enclosed in (...)")
+ in.errorOrMigrationWarning(s"This syntax is no longer supported; parameter needs to be enclosed in (...)")
in.nextToken()
val t = infixType()
if (false && in.isScala2Mode) {
@@ -1933,7 +1942,7 @@ object Parsers {
infixPattern() match {
case pt @ Ident(tpnme.WILDCARD_STAR) =>
if (ctx.settings.strict.value)
- migrationWarningOrError("The syntax `x @ _*' is no longer supported; use `x : _*' instead", startOffset(p))
+ in.errorOrMigrationWarning("The syntax `x @ _*' is no longer supported; use `x : _*' instead", Span(startOffset(p)))
atSpan(startOffset(p), offset) { Typed(p, pt) }
case pt =>
atSpan(startOffset(p), 0) { Bind(name, pt) }
@@ -1941,7 +1950,7 @@ object Parsers {
case p @ Ident(tpnme.WILDCARD_STAR) =>
// compatibility for Scala2 `_*` syntax
if (ctx.settings.strict.value)
- migrationWarningOrError("The syntax `_*' is no longer supported; use `x : _*' instead", startOffset(p))
+ in.errorOrMigrationWarning("The syntax `_*' is no longer supported; use `x : _*' instead", Span(startOffset(p)))
atSpan(startOffset(p)) { Typed(Ident(nme.WILDCARD), p) }
case p =>
p
diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
index 66dcad5099fc..78bed73dce3a 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
@@ -663,7 +663,7 @@ object Scanners {
skipComment()
}
else if (ch == '*') {
- do nextChar() while (ch == '*')
+ while ({ nextChar() ; ch == '*' }) ()
if (ch == '/') nextChar()
else skipComment()
}
@@ -703,17 +703,20 @@ object Scanners {
/** Is the token following the current one in `tokens`? */
def lookaheadIn(tokens: BitSet): Boolean = {
val lookahead = lookaheadScanner
- do lookahead.nextToken()
- while (lookahead.token == NEWLINE || lookahead.token == NEWLINES)
+ while ({
+ lookahead.nextToken()
+ lookahead.token == NEWLINE || lookahead.token == NEWLINES
+ }) ()
tokens.contains(lookahead.token)
}
/** Is the current token in a position where a modifier is allowed? */
def inModifierPosition(): Boolean = {
val lookahead = lookaheadScanner
- do lookahead.nextToken()
- while (lookahead.token == NEWLINE || lookahead.token == NEWLINES ||
- lookahead.isSoftModifier)
+ while ({
+ lookahead.nextToken()
+ lookahead.token == NEWLINE || lookahead.token == NEWLINES || lookahead.isSoftModifier
+ }) ()
modifierFollowers.contains(lookahead.token)
}
@@ -866,10 +869,11 @@ object Scanners {
next.token = LBRACE
} else if (Character.isUnicodeIdentifierStart(ch) || ch == '_') {
finishStringPart()
- do {
+ while ({
putChar(ch)
nextRawChar()
- } while (ch != SU && Character.isUnicodeIdentifierPart(ch))
+ ch != SU && Character.isUnicodeIdentifierPart(ch)
+ }) ()
finishNamed(target = next)
} else {
error("invalid string interpolation: `$$', `$'ident or `$'BlockExpr expected")
diff --git a/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala
index d51bbfe6f7ca..08f140d96ff3 100644
--- a/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/xml/MarkupParserCommon.scala
@@ -110,8 +110,7 @@ private[dotty] trait MarkupParserCommon {
val buf = new StringBuilder
- do buf append ch_returning_nextch
- while (isNameChar(ch))
+ while ({ buf append ch_returning_nextch ; isNameChar(ch) }) ()
if (buf.last == ':') {
reportSyntaxError( "name cannot end in ':'" )
diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index 108d1afa293b..39b50fe6c693 100644
--- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -584,8 +584,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
"(" ~ toTextGlobal(t) ~ ")"
case Tuple(ts) =>
"(" ~ toTextGlobal(ts, ", ") ~ ")"
- case DoWhile(cond, body) =>
- changePrec(GlobalPrec) { keywordStr("do ") ~ toText(body) ~ keywordStr(" while ") ~ toText(cond) }
case ForYield(enums, expr) =>
forText(enums, expr, keywordStr(" yield "))
case ForDo(enums, expr) =>
diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionInternal.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionInternal.scala
index 2a991b0d4fab..8a359539f4bc 100644
--- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionInternal.scala
+++ b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionInternal.scala
@@ -455,7 +455,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
}
/** Normalizes non Blocks.
- * i) Put `while` and `doWhile` loops in their own blocks: `{ def while$() = ...; while$() }`
+ * i) Put `while` loops in their own blocks: `{ def while$() = ...; while$() }`
* ii) Put closures in their own blocks: `{ def anon$() = ...; closure(anon$, ...) }`
*/
private def normalizedLoops(tree: tpd.Tree) given Context: tpd.Tree = tree match {
diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
index 4bd73238797b..b2a301fc7d84 100644
--- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -252,7 +252,7 @@ object LambdaLift {
/** Compute final free variables map `fvs by closing over caller dependencies. */
private def computeFreeVars()(implicit ctx: Context): Unit =
- do {
+ while ({
changedFreeVars = false
for {
caller <- called.keys
@@ -260,11 +260,12 @@ object LambdaLift {
fvs <- free get callee
fv <- fvs
} markFree(fv, caller)
- } while (changedFreeVars)
+ changedFreeVars
+ }) ()
/** Compute final liftedOwner map by closing over caller dependencies */
private def computeLiftedOwners()(implicit ctx: Context): Unit =
- do {
+ while ({
changedLiftedOwner = false
for {
caller <- called.keys
@@ -282,7 +283,8 @@ object LambdaLift {
narrowLiftedOwner(caller, calleeOwner)
}
}
- } while (changedLiftedOwner)
+ changedLiftedOwner
+ }) ()
private def newName(sym: Symbol)(implicit ctx: Context): Name =
if (sym.isAnonymousFunction && sym.owner.is(Method))
diff --git a/compiler/src/dotty/tools/dotc/util/CommentParsing.scala b/compiler/src/dotty/tools/dotc/util/CommentParsing.scala
index 1c02a473b0b6..4c5036121fa8 100644
--- a/compiler/src/dotty/tools/dotc/util/CommentParsing.scala
+++ b/compiler/src/dotty/tools/dotc/util/CommentParsing.scala
@@ -172,8 +172,10 @@ object CommentParsing {
def skipVariable(str: String, start: Int): Int = {
var idx = start
if (idx < str.length && (str charAt idx) == '{') {
- do idx += 1
- while (idx < str.length && (str charAt idx) != '}')
+ while {
+ idx += 1
+ idx < str.length && (str charAt idx) != '}'
+ } do ()
if (idx < str.length) idx + 1 else start
} else {
while (idx < str.length && isVarPart(str charAt idx))
diff --git a/compiler/src/dotty/tools/dotc/util/ShowPickled.scala b/compiler/src/dotty/tools/dotc/util/ShowPickled.scala
index e210f80c73e4..bb7bc52febc9 100644
--- a/compiler/src/dotty/tools/dotc/util/ShowPickled.scala
+++ b/compiler/src/dotty/tools/dotc/util/ShowPickled.scala
@@ -101,12 +101,12 @@ object ShowPickled {
var idx = index
var result = 0L
var b = 0L
- do {
+ while ({
b = data(idx)
idx += 1
result = (result << 7) + (b & 0x7f)
- } while((b & 0x80) != 0L)
-
+ (b & 0x80) != 0L
+ }) ()
result.toInt
}
diff --git a/compiler/test/dotty/tools/dotc/parsing/parsePackage.scala b/compiler/test/dotty/tools/dotc/parsing/parsePackage.scala
index a72016e82bfe..8d1fa2eee7f5 100644
--- a/compiler/test/dotty/tools/dotc/parsing/parsePackage.scala
+++ b/compiler/test/dotty/tools/dotc/parsing/parsePackage.scala
@@ -43,8 +43,6 @@ object parsePackage extends ParserTest {
Tuple(ts map transform)
case WhileDo(cond, body) =>
WhileDo(transform(cond), transform(body))
- case DoWhile(body, cond) =>
- DoWhile(transform(body), transform(cond))
case ForYield(enums, expr) =>
ForYield(enums map transform, transform(expr))
case ForDo(enums, expr) =>
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala
index 1d3aae5499ae..3220e08bf13b 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala
@@ -169,7 +169,7 @@ private[comment] final class WikiParser(
return ""
}
- do {
+ while {
val str = readUntil { char == safeTagMarker || char == endOfText }
nextChar()
@@ -188,7 +188,8 @@ private[comment] final class WikiParser(
}
case _ => ;
}
- } while (stack.length > 0 && char != endOfText)
+ stack.length > 0 && char != endOfText
+ } do ()
list mkString ""
}
diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md
index 9844bd296abb..0078638044a2 100644
--- a/docs/docs/internals/syntax.md
+++ b/docs/docs/internals/syntax.md
@@ -192,7 +192,6 @@ Expr1 ::= ‘if’ ‘(’ Expr ‘)’ {nl}
| ‘if’ Expr ‘then’ Expr [[semi] ‘else’ Expr] If(cond, thenp, elsep?)
| ‘while’ ‘(’ Expr ‘)’ {nl} Expr WhileDo(Parens(cond), body)
| ‘while’ Expr ‘do’ Expr WhileDo(cond, body)
- | ‘do’ Expr [semi] ‘while’ Expr DoWhile(expr, cond)
| ‘try’ Expr Catches [‘finally’ Expr] Try(expr, catches, expr?)
| ‘try’ Expr [‘finally’ Expr] Try(expr, Nil, expr?)
| ‘throw’ Expr Throw(expr)
diff --git a/language-server/test/dotty/tools/languageserver/util/actions/CodeRename.scala b/language-server/test/dotty/tools/languageserver/util/actions/CodeRename.scala
index 331e8529e2fd..b7b39edbd702 100644
--- a/language-server/test/dotty/tools/languageserver/util/actions/CodeRename.scala
+++ b/language-server/test/dotty/tools/languageserver/util/actions/CodeRename.scala
@@ -33,10 +33,11 @@ class CodeRename(override val marker: CodeMarker,
withOverridden.foreach { includeOverridden =>
var question: (ShowMessageRequestParams, CompletableFuture[MessageActionItem]) = null
val startTime = System.currentTimeMillis()
- do {
+ while {
Thread.sleep(50)
question = client.requests.get.headOption.orNull
- } while (question == null && System.currentTimeMillis() - startTime < TIMEOUT_MS)
+ question == null && System.currentTimeMillis() - startTime < TIMEOUT_MS
+ } do ()
if (question == null) fail("The server didn't ask about overridden symbols.")
diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan4.scala b/tests/pos-special/strawman-collections/CollectionStrawMan4.scala
index 8a1d3dc97f15..a554c3e8c794 100644
--- a/tests/pos-special/strawman-collections/CollectionStrawMan4.scala
+++ b/tests/pos-special/strawman-collections/CollectionStrawMan4.scala
@@ -467,10 +467,11 @@ object CollectionStrawMan4 {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while {
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ } do ()
hdDefined = true
true
}
diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan5.scala b/tests/pos-special/strawman-collections/CollectionStrawMan5.scala
index 8fea155ed708..ad698fec3615 100644
--- a/tests/pos-special/strawman-collections/CollectionStrawMan5.scala
+++ b/tests/pos-special/strawman-collections/CollectionStrawMan5.scala
@@ -449,10 +449,11 @@ object CollectionStrawMan5 {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while ({
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ }) ()
hdDefined = true
true
}
diff --git a/tests/pos-special/strawman-collections/CollectionStrawMan6.scala b/tests/pos-special/strawman-collections/CollectionStrawMan6.scala
index a2ff42ba783e..37fc529bb2be 100644
--- a/tests/pos-special/strawman-collections/CollectionStrawMan6.scala
+++ b/tests/pos-special/strawman-collections/CollectionStrawMan6.scala
@@ -964,10 +964,11 @@ object CollectionStrawMan6 extends LowPriority {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while {
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ } do ()
hdDefined = true
true
}
diff --git a/tests/pos-with-compiler/tasty/definitions.scala b/tests/pos-with-compiler/tasty/definitions.scala
index 07e822cd851b..a98c8e4d0f45 100644
--- a/tests/pos-with-compiler/tasty/definitions.scala
+++ b/tests/pos-with-compiler/tasty/definitions.scala
@@ -87,7 +87,6 @@ object definitions {
case Repeated(args: List[Term])
case SelectOuter(from: Term, levels: Int, target: Type) // can be generated by inlining
case While(cond: Term, body: Term)
- case DoWhile(body: Term, cond: Term)
}
/** Trees denoting types */
diff --git a/tests/pos/desugar.scala b/tests/pos/desugar.scala
index 7ea56f9c1fb1..a0bbe738e82b 100644
--- a/tests/pos/desugar.scala
+++ b/tests/pos/desugar.scala
@@ -82,7 +82,7 @@ object desugar {
def bar(x: => Int) = x
(x + y) + 1
while (x < 10) x += 1
- do x -= 1 while (x > 0)
+ while ({ x -= 1 ; x > 0 }) ()
}
}
diff --git a/tests/pos/simpleDoWhile.scala b/tests/pos/simpleDoWhile.scala
index 37419dc5d064..0efa98e3cccc 100644
--- a/tests/pos/simpleDoWhile.scala
+++ b/tests/pos/simpleDoWhile.scala
@@ -1,8 +1,9 @@
class Foo {
def foo = {
var i = 1
- do {
+ while ({
i = 0
- } while (i != 0)
+ i != 0
+ }) ()
}
}
diff --git a/tests/pos/t4579.scala b/tests/pos/t4579.scala
index 500ffae40200..4e76ccf2d0de 100644
--- a/tests/pos/t4579.scala
+++ b/tests/pos/t4579.scala
@@ -17,8 +17,10 @@ class LispTokenizer(s: String) extends Iterator[String] {
val start = i
if (isDelimiter(s charAt i)) i += 1
else
- do i = i + 1
- while (!isDelimiter(s charAt i))
+ while {
+ i = i + 1
+ !isDelimiter(s charAt i)
+ } do ()
s.substring(start, i)
} else sys.error("premature end of string")
}
diff --git a/tests/run-bootstrapped/i6710.scala b/tests/run-bootstrapped/i6710.scala
index ce4167aa3f67..e3b634e4cd8a 100644
--- a/tests/run-bootstrapped/i6710.scala
+++ b/tests/run-bootstrapped/i6710.scala
@@ -17,8 +17,8 @@ object Test {
var x = Double.NaN
while(x < 10.0) { x = x + 1; println(x) }
while(x > 10.0) { x = x + 1; println(x) }
- do { x = x + 1; println(x) } while(x < 10.0)
- do { x = x + 1; println(x) } while(x > 10.0)
+ while ({ x = x + 1; println(x) ; x < 10.0 }) ()
+ while ({ x = x + 1; println(x) ; x > 10.0 }) ()
// tests from https://github.com/scala/scala/pull/5207
{
diff --git a/tests/run-macros/quote-inline-function.check b/tests/run-macros/quote-inline-function.check
index 6d758e5c70ca..fea8ac8da71c 100644
--- a/tests/run-macros/quote-inline-function.check
+++ b/tests/run-macros/quote-inline-function.check
@@ -7,11 +7,12 @@ Normal function
f.apply(x$1)
i = i.+(1)
}
- do {
+ while ({
val x$2: scala.Int = i
f.apply(x$2)
i = i.+(1)
- } while (i.<(j))
+ i.<(j)
+ }) ()
}
By name function
@@ -23,9 +24,10 @@ By name function
scala.Predef.println(x$3)
i = i.+(1)
}
- do {
+ while ({
val x$4: scala.Int = i
scala.Predef.println(x$4)
i = i.+(1)
- } while (i.<(j))
+ i.<(j)
+ }) ()
}
diff --git a/tests/run-macros/quote-inline-function/quoted_1.scala b/tests/run-macros/quote-inline-function/quoted_1.scala
index d51517129b8a..eb871606ec75 100644
--- a/tests/run-macros/quote-inline-function/quoted_1.scala
+++ b/tests/run-macros/quote-inline-function/quoted_1.scala
@@ -15,10 +15,11 @@ object Macros {
${f.apply('i)}
i += 1
}
- do {
+ while {
${f.apply('i)}
i += 1
- } while (i < j)
+ i < j
+ } do ()
}
res.show
}
diff --git a/tests/run-macros/tasty-tree-map/quoted_2.scala b/tests/run-macros/tasty-tree-map/quoted_2.scala
index 6c64a07adf3c..256a864f88cd 100644
--- a/tests/run-macros/tasty-tree-map/quoted_2.scala
+++ b/tests/run-macros/tasty-tree-map/quoted_2.scala
@@ -16,7 +16,7 @@ object Test {
println(identityMaped({ val i = 34; i }))
println(identityMaped({ var i = 34; i += 1; i }))
println(identityMaped({ var i = 0; while (i < 36) i += 1; i }))
- println(identityMaped({ var i = 0; do i += 1 while (i < 37); i }))
+ println(identityMaped({ var i = 0; while { i += 1 ; i < 37 } do (); i }))
println(identityMaped(try 38 finally ()))
println(identityMaped(try 39 catch { case _: Error => }))
println(identityMaped(new java.lang.Integer(40)))
diff --git a/tests/run-with-compiler/quote-lib.scala b/tests/run-with-compiler/quote-lib.scala
index 1f51259c7b0e..0d00729d0d7f 100644
--- a/tests/run-with-compiler/quote-lib.scala
+++ b/tests/run-with-compiler/quote-lib.scala
@@ -137,7 +137,7 @@ package liftable {
object Loops {
def liftedWhile(cond: Expr[Boolean])(body: Expr[Unit]) given QuoteContext: Expr[Unit] = '{ while ($cond) $body }
- def liftedDoWhile(body: Expr[Unit])(cond: Expr[Boolean]) given QuoteContext: Expr[Unit] = '{ do $body while ($cond) }
+ def liftedDoWhile(body: Expr[Unit])(cond: Expr[Boolean]) given QuoteContext: Expr[Unit] = '{ while { $body ; $cond } do () }
}
diff --git a/tests/run/CollectionTests.scala b/tests/run/CollectionTests.scala
index c9d2a2bbb51d..c451b350d354 100644
--- a/tests/run/CollectionTests.scala
+++ b/tests/run/CollectionTests.scala
@@ -448,10 +448,11 @@ object CollectionStrawMan5 {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while ({
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ }) ()
hdDefined = true
true
}
diff --git a/tests/run/colltest4/CollectionStrawMan4_1.scala b/tests/run/colltest4/CollectionStrawMan4_1.scala
index bdf5641cb4de..1284a00bc6fc 100644
--- a/tests/run/colltest4/CollectionStrawMan4_1.scala
+++ b/tests/run/colltest4/CollectionStrawMan4_1.scala
@@ -466,10 +466,11 @@ object CollectionStrawMan4 {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while {
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ } do ()
hdDefined = true
true
}
diff --git a/tests/run/colltest5/CollectionStrawMan5_1.scala b/tests/run/colltest5/CollectionStrawMan5_1.scala
index 620359b5c98e..1e29969e3927 100644
--- a/tests/run/colltest5/CollectionStrawMan5_1.scala
+++ b/tests/run/colltest5/CollectionStrawMan5_1.scala
@@ -441,10 +441,11 @@ object CollectionStrawMan5 {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while {
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ } do ()
hdDefined = true
true
}
diff --git a/tests/run/colltest6/CollectionStrawMan6_1.scala b/tests/run/colltest6/CollectionStrawMan6_1.scala
index 4fad57154775..3e045c8cd722 100644
--- a/tests/run/colltest6/CollectionStrawMan6_1.scala
+++ b/tests/run/colltest6/CollectionStrawMan6_1.scala
@@ -965,10 +965,11 @@ object CollectionStrawMan6 extends LowPriority {
private var hdDefined: Boolean = false
def hasNext: Boolean = hdDefined || {
- do {
+ while {
if (!self.hasNext) return false
hd = self.next()
- } while (!p(hd))
+ !p(hd)
+ } do ()
hdDefined = true
true
}
diff --git a/tests/run/t3877.scala b/tests/run/t3877.scala
index 5d8006f4fc34..befe0b79af9d 100644
--- a/tests/run/t3877.scala
+++ b/tests/run/t3877.scala
@@ -29,25 +29,27 @@ object Test {
def test3: Unit = {
var d = 2
var i = 0
- do {
+ while ({
lazy val b = d + 1
d = b
i += 1
println("test3: " + d)
- } while (d < LIMIT && i < LIMIT)
+ d < LIMIT && i < LIMIT
+ }) ()
}
def test4: Unit = {
var d = 2
var i = 0
- do {
+ while ({
lazy val b = d + 1
d = b
i += 1
println("test4: " + d)
if (d >= LIMIT || i >= LIMIT)
return
- } while (true)
+ true
+ }) ()
}
def test5: Unit = {