Skip to content

Commit 75b315b

Browse files
committed
Move loop block condition
1 parent 9db9d9b commit 75b315b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
275275
this += " => "
276276
printTree(rhs)
277277
this += ")"
278-
case expr if isLoopEntryPoint(expr) && stats.size == 1 =>
279-
// Print { def while$() = ...; while$() }
280-
// as while (...) ...
281-
// instead of { while (...) ... }
282-
printTree(stats.head)
283278
case _ =>
284279
this += "{"
285280
indented {
@@ -753,13 +748,15 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
753748
private object While {
754749
def unapply(arg: Tree)(implicit ctx: Context): Option[(Term, List[Statement])] = arg match {
755750
case DefDef("while$", _, _, _, Some(Term.If(cond, Term.Block(bodyStats, _), _))) => Some((cond, bodyStats))
751+
case Term.Block(List(tree), _) => unapply(tree)
756752
case _ => None
757753
}
758754
}
759755

760756
private object DoWhile {
761757
def unapply(arg: Tree)(implicit ctx: Context): Option[(List[Statement], Term)] = arg match {
762758
case DefDef("doWhile$", _, _, _, Some(Term.Block(body, Term.If(cond, _, _)))) => Some((body, cond))
759+
case Term.Block(List(tree), _) => unapply(tree)
763760
case _ => None
764761
}
765762
}

0 commit comments

Comments
 (0)