@@ -14,11 +14,11 @@ object Deriving {
14
14
sealed abstract class Mirror {
15
15
16
16
/** The mirrored *-type */
17
- type MonoType
17
+ type _MonoType
18
18
}
19
- type MirrorOf [T ] = Mirror { type MonoType = T }
20
- type ProductMirrorOf [T ] = Mirror .Product { type MonoType = T }
21
- type SumMirrorOf [T ] = Mirror .Sum { type MonoType = T }
19
+ type MirrorOf [T ] = Mirror { type _MonoType = T }
20
+ type ProductMirrorOf [T ] = Mirror .Product { type _MonoType = T }
21
+ type SumMirrorOf [T ] = Mirror .Sum { type _MonoType = T }
22
22
23
23
object Mirror {
24
24
@@ -28,7 +28,7 @@ object Deriving {
28
28
type ElemTypes <: Tuple
29
29
30
30
/** The ordinal number of the case class of `x`. For enums, `ordinal(x) == x.ordinal` */
31
- def ordinal (x : MonoType ): Int
31
+ def ordinal (x : _MonoType ): Int
32
32
}
33
33
34
34
/** The Mirror for a product type */
@@ -44,12 +44,12 @@ object Deriving {
44
44
type ElemLabels <: Tuple
45
45
46
46
/** Create a new instance of type `T` with elements taken from product `p`. */
47
- def fromProduct (p : scala.Product ): MonoType
47
+ def _fromProduct (p : scala.Product ): _MonoType
48
48
}
49
49
50
50
trait Singleton extends Product {
51
- type MonoType = this .type
52
- def fromProduct (p : scala.Product ) = this
51
+ type _MonoType = this .type
52
+ def _fromProduct (p : scala.Product ) = this
53
53
}
54
54
}
55
55
@@ -74,30 +74,30 @@ import Deriving._
74
74
sealed trait Lst [+ T ] // derives Eq, Pickler, Show
75
75
76
76
object Lst extends Mirror .Sum {
77
- type MonoType = Lst [_]
77
+ type _MonoType = Lst [_]
78
78
79
79
def ordinal (x : Lst [_]) = x match {
80
80
case x : Cons [_] => 0
81
81
case Nil => 1
82
82
}
83
83
84
84
implicit def mirror [T ]: Mirror .Sum {
85
- type MonoType = Lst [T ]
85
+ type _MonoType = Lst [T ]
86
86
type ElemTypes = (Cons [T ], Nil .type )
87
87
} = this .asInstanceOf
88
88
89
89
case class Cons [T ](hd : T , tl : Lst [T ]) extends Lst [T ]
90
90
91
91
object Cons extends Mirror .Product {
92
- type MonoType = Lst [_]
92
+ type _MonoType = Lst [_]
93
93
94
94
def apply [T ](x : T , xs : Lst [T ]): Lst [T ] = new Cons (x, xs)
95
95
96
- def fromProduct (p : Product ): Cons [_] =
96
+ def _fromProduct (p : Product ): Cons [_] =
97
97
new Cons (productElement[Any ](p, 0 ), productElement[Lst [Any ]](p, 1 ))
98
98
99
99
implicit def mirror [T ]: Mirror .Product {
100
- type MonoType = Cons [T ]
100
+ type _MonoType = Cons [T ]
101
101
type ElemTypes = (T , Lst [T ])
102
102
type CaseLabel = " Cons"
103
103
type ElemLabels = (" hd" , " tl" )
@@ -107,7 +107,7 @@ object Lst extends Mirror.Sum {
107
107
case object Nil extends Lst [Nothing ] with Mirror .Singleton {
108
108
109
109
implicit def mirror : Mirror .Singleton {
110
- type MonoType = Nil .type
110
+ type _MonoType = Nil .type
111
111
type ElemTypes = Unit
112
112
type CaseLabel = " Nil"
113
113
type ElemLabels = Unit
@@ -125,13 +125,13 @@ object Lst extends Mirror.Sum {
125
125
case class Pair [T ](x : T , y : T ) // derives Eq, Pickler, Show
126
126
127
127
object Pair extends Mirror .Product {
128
- type MonoType = Pair [_]
128
+ type _MonoType = Pair [_]
129
129
130
- def fromProduct (p : Product ): Pair [_] =
130
+ def _fromProduct (p : Product ): Pair [_] =
131
131
Pair (productElement[Any ](p, 0 ), productElement[Any ](p, 1 ))
132
132
133
133
implicit def mirror [T ]: Mirror .Product {
134
- type MonoType = Pair [T ]
134
+ type _MonoType = Pair [T ]
135
135
type ElemTypes = (T , T )
136
136
type CaseLabel = " Pair"
137
137
type ElemLabels = (" x" , " y" )
@@ -148,15 +148,15 @@ object Pair extends Mirror.Product {
148
148
sealed trait Either [+ L , + R ] extends Product with Serializable // derives Eq, Pickler, Show
149
149
150
150
object Either extends Mirror .Sum {
151
- type MonoType = Either [_, _]
151
+ type _MonoType = Either [_, _]
152
152
153
153
def ordinal (x : Either [_, _]) = x match {
154
154
case x : Left [_] => 0
155
155
case x : Right [_] => 1
156
156
}
157
157
158
158
implicit def mirror [L , R ]: Mirror .Sum {
159
- type MonoType = Either [L , R ]
159
+ type _MonoType = Either [L , R ]
160
160
type ElemTypes = (Left [L ], Right [R ])
161
161
} = this .asInstanceOf
162
162
@@ -169,21 +169,21 @@ case class Left[L](elem: L) extends Either[L, Nothing]
169
169
case class Right [R ](elem : R ) extends Either [Nothing , R ]
170
170
171
171
object Left extends Mirror .Product {
172
- type MonoType = Left [_]
173
- def fromProduct (p : Product ): Left [_] = Left (productElement[Any ](p, 0 ))
172
+ type _MonoType = Left [_]
173
+ def _fromProduct (p : Product ): Left [_] = Left (productElement[Any ](p, 0 ))
174
174
implicit def mirror [L ]: Mirror .Product {
175
- type MonoType = Left [L ]
175
+ type _MonoType = Left [L ]
176
176
type ElemTypes = L *: Unit
177
177
type CaseLabel = " Left"
178
178
type ElemLabels = " x" *: Unit
179
179
} = this .asInstanceOf
180
180
}
181
181
182
182
object Right extends Mirror .Product {
183
- type MonoType = Right [_]
184
- def fromProduct (p : Product ): Right [_] = Right (productElement[Any ](p, 0 ))
183
+ type _MonoType = Right [_]
184
+ def _fromProduct (p : Product ): Right [_] = Right (productElement[Any ](p, 0 ))
185
185
implicit def mirror [R ]: Mirror .Product {
186
- type MonoType = Right [R ]
186
+ type _MonoType = Right [R ]
187
187
type ElemTypes = R *: Unit
188
188
type CaseLabel = " Right"
189
189
type ElemLabels = " x" *: Unit
@@ -293,11 +293,11 @@ object Pickler {
293
293
inline def unpickleCase [T , Elems <: Tuple ](buf : mutable.ListBuffer [Int ], m : ProductMirrorOf [T ]): T = {
294
294
inline val size = constValue[Tuple .Size [Elems ]]
295
295
inline if (size == 0 )
296
- m.fromProduct (EmptyProduct )
296
+ m._fromProduct (EmptyProduct )
297
297
else {
298
298
val elems = new ArrayProduct (size)
299
299
unpickleElems[Elems ](0 )(buf, elems)
300
- m.fromProduct (elems)
300
+ m._fromProduct (elems)
301
301
}
302
302
}
303
303
0 commit comments