diff --git a/core/src/main/scala/shapeless/generic.scala b/core/src/main/scala/shapeless/generic.scala index 8fee7c6aa..6f27a3861 100644 --- a/core/src/main/scala/shapeless/generic.scala +++ b/core/src/main/scala/shapeless/generic.scala @@ -1025,7 +1025,7 @@ class GenericMacros(val c: whitebox.Context) extends CaseClassMacros { val (p, ts) = ctorDtor.binding val to = cq"$p => ${mkHListValue(ts)}.asInstanceOf[$repr]" val (rp, rts) = ctorDtor.reprBinding - val from = cq"$rp => ${ctorDtor.construct(rts)}" + val from = cq"$rp => ${ctorDtor.construct(rts)}.asInstanceOf[$tpe]" q"$generic.instance[$tpe, $repr]({ case $to }, { case $from })" } diff --git a/core/src/test/scala_2.13+/shapeless/LabelledGenericTests213.scala b/core/src/test/scala_2.13+/shapeless/LabelledGenericTests213.scala new file mode 100644 index 000000000..4bc204df6 --- /dev/null +++ b/core/src/test/scala_2.13+/shapeless/LabelledGenericTests213.scala @@ -0,0 +1,22 @@ +package shapeless + +import org.junit.Assert._ +import org.junit.Test +import shapeless.ops.record.Selector + +class LabelledGenericTests213 { + import LabelledGenericTests213._ + + @Test + def testSelectorWithHkt(): Unit = { + assertEquals(0, new Func[Hkt[Option]].select(Symbol("foo"))) + assertEquals(0, new Func[Hkt[Id]].select(Symbol("foo"))) + } +} + +object LabelledGenericTests213 { + case class Hkt[F[_]](foo: F[String]) + class Func[T] { + def select[R <: HList](k: Witness)(implicit gen: LabelledGeneric.Aux[T, R], selector: Selector[R, k.T]) = 0 + } +}