Skip to content

Commit 0164aea

Browse files
committed
fixup! fixup! Add SeqSet and SetFromMap implementations
dynamic `className` impl using `collectionClassName`
1 parent b0938ab commit 0164aea

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

src/main/scala/scala/collection/SetFromMap.scala

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ private class SetFromMap[A](protected[collection] val underlying: Map[A, Unit])
2020
extends AbstractSet[A]
2121
with SetFromMapOps.Unknown[A, Map, Map[A, Unit], SetFromMap, SetFromMap[A]]
2222
with SetFromMapOps.Unsorted[A, Map, SetFromMap]
23+
with SetFromMapOps.DynamicClassName
2324
with IterableFactoryDefaults[A, SetFromMap]
2425
with DefaultSerializable {
2526
protected[this] def fromMap[B](m: Map[B, Unit]): SetFromMap[B] = new SetFromMap(m)
2627

27-
override protected[this] def className: String = "SetFromMap"
28-
2928
override def iterableFactory: IterableFactory[SetFromMap] =
3029
new SetFromMap.WrapperFactory(underlying.mapFactory)
3130
}
@@ -48,13 +47,12 @@ private class SeqSetFromMap[A](protected[collection] val underlying: SeqMap[A, U
4847
extends AbstractSet[A]
4948
with SetFromMapOps.Unknown[A, SeqMap, SeqMap[A, Unit], SeqSetFromMap, SeqSetFromMap[A]]
5049
with SetFromMapOps.Unsorted[A, SeqMap, SeqSetFromMap]
50+
with SetFromMapOps.DynamicClassName
5151
with SeqSet[A]
5252
with IterableFactoryDefaults[A, SeqSetFromMap]
5353
with DefaultSerializable {
5454
protected[this] def fromMap[B](m: SeqMap[B, Unit]): SeqSetFromMap[B] = new SeqSetFromMap(m)
5555

56-
override protected[this] def className: String = "SeqSetFromMap"
57-
5856
override def iterableFactory: IterableFactory[SeqSetFromMap] =
5957
new SeqSetFromMap.WrapperFactory(underlying.mapFactory)
6058
}
@@ -77,6 +75,7 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
7775
extends AbstractSet[A]
7876
with SetFromMapOps.Unknown[A, Map, SortedMap[A, Unit], Set, SortedSetFromMap[A]]
7977
with SetFromMapOps.Sorted[A, SortedMap, Set, SortedSetFromMap]
78+
with SetFromMapOps.DynamicClassName
8079
with SortedSet[A]
8180
with SortedSetOps[A, SortedSetFromMap, SortedSetFromMap[A]]
8281
with IterableFactoryDefaults[A, Set]
@@ -87,8 +86,6 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
8786
protected[this] def fromSortedMap[B: Ordering](m: SortedMap[B, Unit]): SortedSetFromMap[B] =
8887
new SortedSetFromMap(m)
8988

90-
override protected[this] def className: String = "SortedSetFromMap"
91-
9289
override def iterableFactory: IterableFactory[Set] = SetFromMap(underlying.mapFactory)
9390

9491
override def sortedIterableFactory: SortedIterableFactory[SortedSetFromMap] =

src/main/scala/scala/collection/SetFromMapOps.scala

+6
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ object SetFromMapOps {
177177
protected[collection] val underlying: IterableOnce[(A, Unit)]
178178
}
179179

180+
trait DynamicClassName { self: Iterable[_] =>
181+
protected[collection] val underlying: Iterable[_]
182+
183+
override protected[this] def className: String = s"SetFrom_${underlying.collectionClassName}"
184+
}
185+
180186
// unknown whether mutable or immutable
181187
trait Unknown[
182188
A,

src/main/scala/scala/collection/immutable/SetFromMap.scala

+3-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ object SetFromMapOps {
4848
private class SetFromMap[A](protected[collection] val underlying: Map[A, Unit])
4949
extends AbstractSet[A]
5050
with SetFromMapOps.Unsorted[A, Map, SetFromMap]
51+
with collection.SetFromMapOps.DynamicClassName
5152
with IterableFactoryDefaults[A, SetFromMap]
5253
with DefaultSerializable {
5354
protected[this] def fromMap[B](m: Map[B, Unit]): SetFromMap[B] = new SetFromMap(m)
5455

55-
override protected[this] def className: String = "SetFromMap"
56-
5756
override def iterableFactory: IterableFactory[SetFromMap] =
5857
new SetFromMap.WrapperFactory(underlying.mapFactory)
5958
}
@@ -75,14 +74,13 @@ private object SetFromMap extends SetFromMapMetaFactory[Map, Set] {
7574
private class SeqSetFromMap[A](protected[collection] val underlying: SeqMap[A, Unit])
7675
extends AbstractSet[A]
7776
with SetFromMapOps.Unsorted[A, SeqMap, SeqSetFromMap]
77+
with collection.SetFromMapOps.DynamicClassName
7878
with SeqSet[A]
7979
with IterableFactoryDefaults[A, SeqSetFromMap]
8080
with DefaultSerializable {
8181
protected[this] def fromMap[B](m: SeqMap[B, Unit]): SeqSetFromMap[B] =
8282
new SeqSetFromMap(m)
8383

84-
override protected[this] def className: String = "SeqSetFromMap"
85-
8684
override def iterableFactory: IterableFactory[SeqSetFromMap] =
8785
new SeqSetFromMap.WrapperFactory(underlying.mapFactory)
8886
}
@@ -105,6 +103,7 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
105103
extends AbstractSet[A]
106104
with SetFromMapOps[A, Map, SortedMap[A, Unit], Set, SortedSetFromMap[A]]
107105
with collection.SetFromMapOps.Sorted[A, SortedMap, Set, SortedSetFromMap]
106+
with collection.SetFromMapOps.DynamicClassName
108107
with SortedSet[A]
109108
with SortedSetOps[A, SortedSetFromMap, SortedSetFromMap[A]]
110109
with IterableFactoryDefaults[A, Set]
@@ -118,8 +117,6 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
118117
protected[this] def fromSortedMap[B: Ordering](m: SortedMap[B, Unit]): SortedSetFromMap[B] =
119118
new SortedSetFromMap(m)
120119

121-
override protected[this] def className: String = "SortedSetFromMap"
122-
123120
override def iterableFactory: IterableFactory[Set] = SetFromMap(underlying.mapFactory)
124121

125122
override def sortedIterableFactory: SortedIterableFactory[SortedSetFromMap] =

src/main/scala/scala/collection/mutable/SetFromMap.scala

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ private[collection] class SetFromMap[A](protected[collection] val underlying: Ma
5454
extends AbstractSet[A]
5555
with SetFromMapOps[A, Map, Map[A, Unit], SetFromMap, SetFromMap[A]]
5656
with SetFromMapOps.Unsorted[A, Map, SetFromMap]
57+
with SetFromMapOps.DynamicClassName
5758
with IterableFactoryDefaults[A, SetFromMap]
5859
with DefaultSerializable {
5960
protected[this] def fromMap[B](m: Map[B, Unit]): SetFromMap[B] = new SetFromMap(m)
6061

61-
override protected[this] def className: String = "SetFromMap"
62-
6362
override def iterableFactory: IterableFactory[SetFromMap] = SetFromMap(underlying.mapFactory)
6463
}
6564

@@ -81,13 +80,12 @@ private class SeqSetFromMap[A](protected[collection] val underlying: SeqMap[A, U
8180
extends AbstractSet[A]
8281
with SetFromMapOps[A, SeqMap, SeqMap[A, Unit], SeqSetFromMap, SeqSetFromMap[A]]
8382
with SetFromMapOps.Unsorted[A, SeqMap, SeqSetFromMap]
83+
with SetFromMapOps.DynamicClassName
8484
with SeqSet[A]
8585
with IterableFactoryDefaults[A, SeqSetFromMap]
8686
with DefaultSerializable {
8787
protected[this] def fromMap[B](m: SeqMap[B, Unit]): SeqSetFromMap[B] = new SeqSetFromMap(m)
8888

89-
override protected[this] def className: String = "SeqSetFromMap"
90-
9189
override def iterableFactory: IterableFactory[SeqSetFromMap] = SeqSetFromMap(underlying.mapFactory)
9290
}
9391

@@ -109,6 +107,7 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
109107
extends AbstractSet[A]
110108
with SetFromMapOps[A, Map, SortedMap[A, Unit], Set, SortedSetFromMap[A]]
111109
with SetFromMapOps.Sorted[A, SortedMap, Set, SortedSetFromMap]
110+
with SetFromMapOps.DynamicClassName
112111
with SortedSet[A]
113112
with SortedSetOps[A, SortedSetFromMap, SortedSetFromMap[A]]
114113
with IterableFactoryDefaults[A, Set]
@@ -119,8 +118,6 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
119118
protected[this] def fromSortedMap[B: Ordering](m: SortedMap[B, Unit]): SortedSetFromMap[B] =
120119
new SortedSetFromMap(m)
121120

122-
override protected[this] def className: String = "SortedSetFromMap"
123-
124121
override def iterableFactory: IterableFactory[SetFromMap] = SetFromMap(underlying.mapFactory)
125122

126123
override def sortedIterableFactory: SortedIterableFactory[SortedSetFromMap] =

0 commit comments

Comments
 (0)