Skip to content

Commit 97c5463

Browse files
committed
test case: Make case objects be their own generic instances
1 parent 4d84b4c commit 97c5463

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tests/run/typeclass-derivation2c.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object Deriving {
5757
def fromProduct(p: scala.Product): T
5858
}
5959

60-
class Singleton[T] extends Generic[T] {
60+
trait Singleton[T] extends Generic[T] {
6161
inline def singletonValue = implicit match {
6262
case ev: ValueOf[T] => ev.value
6363
}
@@ -105,11 +105,9 @@ object Lst {
105105
implicit def GenericCons[T]: GenericCons[T] = new GenericCons[T]
106106
}
107107

108-
case object Nil extends Lst[Nothing] {
109-
class GenericNil extends Generic.Singleton[Nil.type] {
110-
type CaseLabel = "Nil"
111-
}
112-
implicit def GenericNil: GenericNil = new GenericNil
108+
case object Nil extends Lst[Nothing] with Generic.Singleton[Nil.type] {
109+
type CaseLabel = "Nil"
110+
implicit def GenericNil: Nil.type = this
113111
}
114112

115113
// three clauses that would be generated from a `derives` clause

0 commit comments

Comments
 (0)