Skip to content

Commit

Permalink
Merge pull request #1152 from joroKr21/modules
Browse files Browse the repository at this point in the history
Fix Coproduct case object singleton types
  • Loading branch information
joroKr21 authored May 7, 2021
2 parents 86db91c + e679c05 commit 88e249f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/shapeless/generic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ trait CaseClassMacros extends ReprTypes with CaseClassMacrosVersionSpecifics {

val ctor = if (isNamed) {
if (sym.isModuleClass) {
sym.toTypeIn(pre)
singleType(pre, sym.module)
} else {
val subst = thisType(sym).baseType(baseSym).typeArgs.map(_.typeSymbol)
val params = sym.typeParams
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/scala/shapeless/ops/coproduct.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1262,10 +1262,12 @@ object coproduct {
object LiftAll {
type Aux[F[_], In0 <: Coproduct, Out0 <: HList] = LiftAll[F, In0] {type Out = Out0}

class Curried[F[_]] {def apply[In <: Coproduct](in: In)(implicit ev: LiftAll[F, In]) = ev}
class Curried[F[_]] {
def apply[In <: Coproduct](in: In)(implicit ev: LiftAll[F, In]): Aux[F, In, ev.Out] = ev
}

def apply[F[_]] = new Curried[F]
def apply[F[_], In <: Coproduct](implicit ev: LiftAll[F, In]) = ev
def apply[F[_]]: Curried[F] = new Curried[F]
def apply[F[_], In <: Coproduct](implicit ev: LiftAll[F, In]): Aux[F, In, ev.Out] = ev

implicit def liftAllCnil[F[_]]: LiftAll.Aux[F, CNil, HNil] = new LiftAll[F, CNil] {
type Out = HNil
Expand Down
3 changes: 3 additions & 0 deletions core/src/test/scala/shapeless/generic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ class GenericTests {

val c1 = gen.from(c0)
typed[Enum](c1)

val abc = ops.coproduct.LiftAll[Witness.Aux, gen.Repr]
assertEquals(List(A, B, C), abc.instances.toList.map(_.value))
}

@Test
Expand Down

0 comments on commit 88e249f

Please sign in to comment.