Skip to content

Commit 2fd665d

Browse files
committed
fixup! fixup! Add SeqSet and SetFromMap implementations
dynamic `className` impl using `collectionClassName`
1 parent 023ba1b commit 2fd665d

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

Diff for: 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
}
@@ -79,6 +77,7 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
7977
) extends AbstractSet[A]
8078
with SetFromMapOps.Unknown[A, Map, SortedMap[A, Unit], Set, SortedSetFromMap[A]]
8179
with SetFromMapOps.Sorted[A, SortedMap, Set, SortedSetFromMap]
80+
with SetFromMapOps.DynamicClassName
8281
with SortedSet[A]
8382
with SortedSetOps[A, SortedSetFromMap, SortedSetFromMap[A]]
8483
with IterableFactoryDefaults[A, Set]
@@ -89,8 +88,6 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
8988
protected[this] def fromSortedMap[B: Ordering](m: SortedMap[B, Unit]): SortedSetFromMap[B] =
9089
new SortedSetFromMap(m)
9190

92-
override protected[this] def className: String = "SortedSetFromMap"
93-
9491
override def iterableFactory: IterableFactory[Set] = SetFromMap(underlying.mapFactory)
9592

9693
override def sortedIterableFactory: SortedIterableFactory[SortedSetFromMap] =

Diff for: src/main/scala/scala/collection/SetFromMapOps.scala

+6
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ object SetFromMapOps {
196196
protected[collection] val underlying: IterableOnce[(A, Unit)]
197197
}
198198

199+
trait DynamicClassName { self: Iterable[_] =>
200+
protected[collection] val underlying: Iterable[_]
201+
202+
override protected[this] def className: String = s"SetFrom_${underlying.collectionClassName}"
203+
}
204+
199205
// unknown whether mutable or immutable
200206
trait Unknown[
201207
A,

Diff for: src/main/scala/scala/collection/immutable/SetFromMap.scala

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

53-
override protected[this] def className: String = "SetFromMap"
54-
5554
override def iterableFactory: IterableFactory[SetFromMap] =
5655
new SetFromMap.WrapperFactory(underlying.mapFactory)
5756
}
@@ -73,14 +72,13 @@ private object SetFromMap extends SetFromMapMetaFactory[Map, Set] {
7372
private class SeqSetFromMap[A](protected[collection] val underlying: SeqMap[A, Unit])
7473
extends AbstractSet[A]
7574
with SetFromMapOps.Unsorted[A, SeqMap, SeqSetFromMap]
75+
with collection.SetFromMapOps.DynamicClassName
7676
with SeqSet[A]
7777
with IterableFactoryDefaults[A, SeqSetFromMap]
7878
with DefaultSerializable {
7979
protected[this] def fromMap[B](m: SeqMap[B, Unit]): SeqSetFromMap[B] =
8080
new SeqSetFromMap(m)
8181

82-
override protected[this] def className: String = "SeqSetFromMap"
83-
8482
override def iterableFactory: IterableFactory[SeqSetFromMap] =
8583
new SeqSetFromMap.WrapperFactory(underlying.mapFactory)
8684
}
@@ -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] =

Diff for: src/main/scala/scala/collection/mutable/SetFromMap.scala

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

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

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

88-
override protected[this] def className: String = "SeqSetFromMap"
89-
9088
override def iterableFactory: IterableFactory[SeqSetFromMap] = SeqSetFromMap(
9189
underlying.mapFactory
9290
)
@@ -114,6 +112,7 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
114112
) extends AbstractSet[A]
115113
with SetFromMapOps[A, Map, SortedMap[A, Unit], Set, SortedSetFromMap[A]]
116114
with SetFromMapOps.Sorted[A, SortedMap, Set, SortedSetFromMap]
115+
with SetFromMapOps.DynamicClassName
117116
with SortedSet[A]
118117
with SortedSetOps[A, SortedSetFromMap, SortedSetFromMap[A]]
119118
with IterableFactoryDefaults[A, Set]
@@ -124,8 +123,6 @@ private class SortedSetFromMap[A](protected[collection] val underlying: SortedMa
124123
protected[this] def fromSortedMap[B: Ordering](m: SortedMap[B, Unit]): SortedSetFromMap[B] =
125124
new SortedSetFromMap(m)
126125

127-
override protected[this] def className: String = "SortedSetFromMap"
128-
129126
override def iterableFactory: IterableFactory[SetFromMap] = SetFromMap(underlying.mapFactory)
130127

131128
override def sortedIterableFactory: SortedIterableFactory[SortedSetFromMap] =

0 commit comments

Comments
 (0)