Skip to content

Commit 00cf7f6

Browse files
Mitigate #2924
1 parent af5f4d1 commit 00cf7f6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

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

115-
def foldRightBN[U](z: => U)(op: (T, => U) => U): U = xs match {
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 {
116118
case Nil => z
117-
case x :: xs1 => op(x, xs1.foldRightBN(z)(op))
119+
case x :: xs1 => xs1.foldLeftBN(op(x, z))(op)
118120
}
119121

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

0 commit comments

Comments
 (0)