Skip to content

Commit 3e0246e

Browse files
committed
add in explicit type parameters for variant enums
1 parent a8d07c6 commit 3e0246e

23 files changed

+36
-39
lines changed

tests/neg-custom-args/typeclass-derivation2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ object TypeLevel {
122122

123123
// An algebraic datatype
124124
enum Lst[+T] {
125-
case Cons(hd: T, tl: Lst[T])
125+
case Cons[T](hd: T, tl: Lst[T]) extends Lst[T]
126126
case Nil
127127
}
128128

tests/neg/enum-tparams.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
object Test {
22

33
enum Opt[+T] {
4-
case S(x: T) extends Opt[T]
4+
case S[T](x: T) extends Opt[T]
55
case I(x: Int) extends Opt[Int]
6-
case V() extends Opt[`T`]
7-
case P(x: List[T]) extends Opt[String]
6+
case V[T]() extends Opt[`T`]
7+
case P[T](x: List[T]) extends Opt[String]
88
case N extends Opt[Nothing]
99
}
1010

@@ -37,4 +37,4 @@ object Test {
3737
E.C4() // OK
3838
E.C5[List, Id]() // OK
3939
E.C5() // OK
40-
}
40+
}

tests/neg/enums.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ enum Captured[T] {
3636
}
3737

3838
enum Option[+T] derives Eql {
39-
case Some(x: T)
39+
case Some[T](x: T) extends Option[T]
4040
case None
4141
}
4242

tests/neg/i4470c.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
object DuplicatedEnum {
22
enum Maybe[+T] { // error
3-
case Some(x: T)
3+
case Some[T](x: T) extends Maybe[T]
44
}
55

66
enum Maybe[+T] { // error
7-
case Some(x: T)
7+
case Some[T](x: T) extends Maybe[T]
88
}
99
}

tests/neg/i5495.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
lazy enum LazyList[+A] { // error: sealed abstract types cannot be lazy enum
2-
case :: (head: A, tail: LazyList[A])
2+
case ::[A] (head: A, tail: LazyList[A]) extends LazyList[A]
33
case Nil
4-
}
4+
}

tests/neg/i7459.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ object Eq {
5858

5959

6060
enum Opt[+T] derives Eq {
61-
case Sm(t: T)
61+
case Sm[T](t: T) extends Opt[T]
6262
case Nn
63-
}
63+
}

tests/patmat/enum-approx.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum Fun[-T, +U >: Null] {
88

99
case Identity[T, U >: Null](g: T => U) extends Fun[T, U]
1010
case ConstNull
11-
case ConstNullClass(x: T)
11+
case ConstNullClass[T](x: T) extends Fun[T, Null]
1212
case ConstNullSimple
1313
}
1414

@@ -28,4 +28,3 @@ object Test {
2828
case ConstNullSimple => null
2929
}
3030
}
31-

tests/pos/patmat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object Test {
3535
}
3636

3737
enum Option[+T] {
38-
case Some(value: T)
38+
case Some[T](value: T) extends Option[T]
3939
case None
4040
}
4141
import Option._

tests/pos/reference/adts.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package adts
22
object t1:
33

44
enum Option[+T]:
5-
case Some(x: T)
5+
case Some[T](x: T) extends Option[T]
66
case None
77

88
object t2:
99

1010
enum Option[+T]:
11-
case Some(x: T) extends Option[T]
12-
case None extends Option[Nothing]
11+
case Some[T](x: T) extends Option[T]
12+
case None extends Option[Nothing]
1313

1414
enum Color(val rgb: Int):
1515
case Red extends Color(0xFF0000)
@@ -20,7 +20,7 @@ enum Color(val rgb: Int):
2020
object t3:
2121

2222
enum Option[+T]:
23-
case Some(x: T) extends Option[T]
23+
case Some[T](x: T) extends Option[T]
2424
case None
2525

2626
def isDefined: Boolean = this match

tests/run-custom-args/typeclass-derivation2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ object TypeLevel {
124124

125125
// An algebraic datatype
126126
enum Lst[+T] { // derives Eq, Pickler, Show
127-
case Cons(hd: T, tl: Lst[T])
127+
case Cons[T](hd: T, tl: Lst[T]) extends Lst[T]
128128
case Nil
129129
}
130130

0 commit comments

Comments
 (0)