After updating to Scala 2.13 I came across some unexpected behavior in iteration over a Java set using JavaConverters. I had a set of size 1 which appeared to result in two “loops” within a for comprehension. You can see this by performing a side effect when mapping over the set:
Welcome to Scala 2.13.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_141). Type in expressions for evaluation. Or try :help. scala> import scala.collection.JavaConverters._ import scala.collection.JavaConverters._ scala> import java.util import java.util scala> val jSet = new util.HashSet[String]() jSet: java.util.HashSet[String] =  scala> jSet.add("hello") res0: Boolean = true scala> jSet.asScala.map(println) warning: there was one deprecation warning (since 2.13.0); for details, enable `:setting -deprecation' or `:replay -deprecation' hello hello res1: scala.collection.mutable.Set[Unit] = HashSet(())
I know it is unexpected to perform side effects within
.map, and the returned set is of the correct size, but should this be considered a bug?