You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Ichoran said:
This is not limited to just +; everything without a CanBuildFrom is affected also. In fact, it's a fundamental weakness of the design where a BitSet cannot actually live up to the requirements of Set. Not sure that there's a good fix for this since we can't restrict to positive integers.
Instead, maybe we should let BitSet hold negative integers. There's no reason it can't.
@szeiger said:
This also affects methods with CanBuildFrom:
scala>vals: scala.collection.immutable.Set[Int] = scala.collection.immutable.BitSet(1,2,3).map(- _)
java.lang.IllegalArgumentException: requirement failed
at scala.Predef$.require(Predef.scala:207)
at scala.collection.mutable.BitSet.add(BitSet.scala:83)
at scala.collection.mutable.BitSet.$plus$eq(BitSet.scala:102)
at scala.collection.immutable.BitSet$$anon$1.$plus$eq(BitSet.scala:74)
at scala.collection.immutable.BitSet$$anon$1.$plus$eq(BitSet.scala:72)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.BitSetLike$class.foreach(BitSetLike.scala:128)
at scala.collection.immutable.BitSet.foreach(BitSet.scala:28)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)
at scala.collection.SetLike$class.map(SetLike.scala:92)
at scala.collection.AbstractSet.map(Set.scala:47)
... 33 elided
This throws an exception, which is not at all expected or expectable when looking at the Set interface.
The + method should be fixed to avoid violating LSP.
The text was updated successfully, but these errors were encountered: