We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a70a3d commit 1eaffd5Copy full SHA for 1eaffd5
src/library/scala/collection/Iterator.scala
@@ -1,7 +1,6 @@
1
package scala.collection
2
3
import java.io.{ObjectInputStream, ObjectOutputStream}
4
-import java.util.Objects
5
6
import scala.collection.mutable.{ArrayBuffer, Builder, ImmutableBuilder}
7
import scala.annotation.tailrec
@@ -1097,7 +1096,11 @@ object Iterator extends IterableFactory[Iterator] {
1097
1096
1098
override def hasNext: Boolean = {
1099
if (nextResult eq null) {
1100
- nextResult = Objects.requireNonNull(f(state), "null during unfold")
+ nextResult = {
+ val res = f(state)
1101
+ if (res eq null) throw new NullPointerException("null during unfold")
1102
+ res
1103
+ }
1104
state = null.asInstanceOf[S] // allow GC
1105
}
1106
nextResult.isDefined
0 commit comments