Skip to content

Commit 896c98d

Browse files
authored
Merge pull request scala/scala#10234 from lrytz/pr10211-no-catch
Don't catch UnsupportedOperationException in IterableOnce.reduceRight
2 parents ec09615 + be27e9e commit 896c98d

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

library/src/scala/collection/IterableOnce.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,7 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
783783
def reduceRight[B >: A](op: (A, B) => B): B = this match {
784784
case seq: IndexedSeq[A @unchecked] if seq.length > 0 => foldr[A, B](seq, op)
785785
case _ if knownSize == 0 => throw new UnsupportedOperationException("empty.reduceRight")
786-
case _ =>
787-
try reversed.reduceLeft[B]((x, y) => op(y, x)) // reduceLeftIterator
788-
catch {
789-
case e: UnsupportedOperationException if e.getMessage == "empty.reduceLeft" =>
790-
throw new UnsupportedOperationException("empty.reduceRight")
791-
}
786+
case _ => reversed.reduceLeft[B]((x, y) => op(y, x)) // reduceLeftIterator
792787
}
793788

794789
/** Optionally applies a binary operator to all elements of this $coll, going left to right.

0 commit comments

Comments
 (0)