File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 1
1
import scala .reflect .ClassTag
2
- import scala .tasty .FlagSet
3
2
4
3
object Test {
5
4
def main (args : Array [String ]): Unit = {
Original file line number Diff line number Diff line change 1
1
CaseClassImplementation
2
- underlying rep: Z()
2
+ underlying rep: Z
3
3
test1 OK
4
4
test2 OK
5
5
6
- underlying rep: S(S(S(Z() )))
6
+ underlying rep: S(S(S(Z)))
7
7
test3 OK
8
- Succ(S(S(Z() ))) = 3
8
+ Succ(S(S(Z))) = 3
9
9
test4 OK
10
- Succ(S(S(Z() ))) = 3
10
+ Succ(S(S(Z))) = 3
11
11
12
12
IntImplementation
13
13
underlying rep: 0
Original file line number Diff line number Diff line change 1
1
import scala .reflect .ClassTag
2
- import scala .tasty .FlagSet
3
2
4
3
object Test {
5
4
def main (args : Array [String ]): Unit = {
@@ -119,7 +118,7 @@ abstract class Numbers {
119
118
object CaseClassImplementation extends Numbers {
120
119
121
120
sealed trait N
122
- final case class Z () extends N
121
+ final object Z extends N { override def toString : String = " Z " }
123
122
final case class S (n : N ) extends N
124
123
125
124
// === Nat ==========================================
@@ -138,12 +137,12 @@ object CaseClassImplementation extends Numbers {
138
137
139
138
// --- Zero ----------------------------------------
140
139
141
- type Zero = Z
140
+ type Zero = Z . type
142
141
143
142
def zeroClassTag : ClassTag [Zero ] = implicitly
144
143
145
144
val Zero : ZeroExtractor = new ZeroExtractor {
146
- def apply (): Zero = new Z ()
145
+ def apply (): Zero = Z
147
146
def unapply (zero : Zero ): Boolean = true // checked by class tag before calling the unapply
148
147
}
149
148
You can’t perform that action at this time.
0 commit comments