Skip to content

Commit 2118a0c

Browse files
authored
Merge pull request #3078 from allanrenucci/0.3.x
Backport #3076
2 parents ec71b47 + 6926796 commit 2118a0c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,12 @@ object Decorators {
112112
else x1 :: xs1
113113
}
114114

115-
def foldRightBN[U](z: => U)(op: (T, => U) => U): U = xs match {
116-
case Nil => z
117-
case x :: xs1 => op(x, xs1.foldRightBN(z)(op))
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)
118121
}
119122

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

0 commit comments

Comments
 (0)