Skip to content

Commit 35b319a

Browse files
nicolasstuckibiboudis
authored andcommitted
Mitigate #2924
1 parent 541908f commit 35b319a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,11 @@ object Decorators {
112112
else x1 :: xs1
113113
}
114114

115-
def foldRightBN[U](z: => U)(op: (T, => U) => U): U = {
116-
@tailrec def foldLeftBN(xs: List[T], acc: => U): U = xs match {
117-
case x :: xs1 => foldLeftBN(xs1, op(x, acc))
118-
case Nil => acc
119-
}
120-
foldLeftBN(xs.reverse, z)
115+
def foldRightBN[U](z: => U)(op: (T, => U) => U): U = xs.reverse.foldLeftBN(z)(op)
116+
117+
@tailrec final def foldLeftBN[U](z: => U)(op: (T, => U) => U): U = xs match {
118+
case Nil => z
119+
case x :: xs1 => xs1.foldLeftBN(op(x, z))(op)
121120
}
122121

123122
final def hasSameLengthAs[U](ys: List[U]): Boolean = {

0 commit comments

Comments
 (0)