Skip to content

Commit bd8509b

Browse files
committed
Nil.min throws UnsupportedOperationException instead of NoSuchElementException
1 parent c1e9bc9 commit bd8509b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/src/main/scala/scala/collection/parallel/ParIterableLike.scala

+2
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ extends IterableOnce[T @uncheckedVariance]
471471
}
472472

473473
def max[U >: T](implicit ord: Ordering[U]): T = {
474+
if (isEmpty) throw new UnsupportedOperationException("empty.max")
475+
474476
tasksupport.executeAndWaitResult(new Max(ord, splitter)).get.asInstanceOf[T]
475477
}
476478

junit/src/test/scala/scala/collection/parallel/mutable/ParArrayTest.scala

+5
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,9 @@ class ParArrayTest extends scala.collection.concurrent.ctries_old.Spec {
138138
evaluating { ParArray.empty[Int].min }.shouldProduce[UnsupportedOperationException]()
139139
}
140140

141+
@Test
142+
def `empty max`: Unit = {
143+
evaluating { ParArray.empty[Int].max }.shouldProduce[UnsupportedOperationException]()
144+
}
145+
141146
}

0 commit comments

Comments
 (0)