@@ -35,7 +35,12 @@ trait Set[A] extends Iterable[A]
3535 override def companion : GenericCompanion [Set ] = Set
3636
3737
38- override def toSet [B >: A ]: Set [B ] = to[({type l [a] = immutable.Set [B ]})# l] // for bincompat; remove in dev
38+ /** Returns this $coll as an immutable map.
39+ *
40+ * A new map will not be built; lazy collections will stay lazy.
41+ */
42+ @ deprecatedOverriding(" Immutable sets should do nothing on toSet but return themselves cast as a Set." , " 2.11.0" )
43+ override def toSet [B >: A ]: Set [B ] = this .asInstanceOf [Set [B ]]
3944
4045 override def seq : Set [A ] = this
4146 protected override def parCombiner = ParSet .newCombiner[A ] // if `immutable.SetLike` gets introduced, please move this there!
@@ -57,7 +62,6 @@ object Set extends ImmutableSetFactory[Set] {
5762 def - (elem : Any ): Set [Any ] = this
5863 def iterator : Iterator [Any ] = Iterator .empty
5964 override def foreach [U ](f : Any => U ): Unit = {}
60- override def toSet [B >: Any ]: Set [B ] = this .asInstanceOf [Set [B ]]
6165 }
6266 private [collection] def emptyInstance : Set [Any ] = EmptySet
6367
@@ -88,8 +92,6 @@ object Set extends ImmutableSetFactory[Set] {
8892 if (f(elem1)) Some (elem1)
8993 else None
9094 }
91- @ deprecatedOverriding(" Immutable sets should do nothing on toSet but return themselves cast as a Set." , " 2.11.0" )
92- override def toSet [B >: A ]: Set [B ] = this .asInstanceOf [Set [B ]]
9395 }
9496
9597 /** An optimized representation for immutable sets of size 2 */
@@ -121,8 +123,6 @@ object Set extends ImmutableSetFactory[Set] {
121123 else if (f(elem2)) Some (elem2)
122124 else None
123125 }
124- @ deprecatedOverriding(" Immutable sets should do nothing on toSet but return themselves cast as a Set." , " 2.11.0" )
125- override def toSet [B >: A ]: Set [B ] = this .asInstanceOf [Set [B ]]
126126 }
127127
128128 /** An optimized representation for immutable sets of size 3 */
@@ -156,8 +156,6 @@ object Set extends ImmutableSetFactory[Set] {
156156 else if (f(elem3)) Some (elem3)
157157 else None
158158 }
159- @ deprecatedOverriding(" Immutable sets should do nothing on toSet but return themselves cast as a Set." , " 2.11.0" )
160- override def toSet [B >: A ]: Set [B ] = this .asInstanceOf [Set [B ]]
161159 }
162160
163161 /** An optimized representation for immutable sets of size 4 */
@@ -193,8 +191,6 @@ object Set extends ImmutableSetFactory[Set] {
193191 else if (f(elem4)) Some (elem4)
194192 else None
195193 }
196- @ deprecatedOverriding(" Immutable sets should do nothing on toSet but return themselves cast as a Set." , " 2.11.0" )
197- override def toSet [B >: A ]: Set [B ] = this .asInstanceOf [Set [B ]]
198194 }
199195}
200196
0 commit comments