Skip to content

Commit

Permalink
Merge pull request #984 from joroKr21/hkt-id-selector
Browse files Browse the repository at this point in the history
Add missing asInstanceOf call
  • Loading branch information
joroKr21 authored Jul 30, 2020
2 parents c9cde2c + 452daab commit 0687c03
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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 @@ -941,7 +941,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 })"
}

Expand Down
22 changes: 22 additions & 0 deletions core/src/test/scala_2.13+/shapeless/LabelledGenericTests213.scala
Original file line number Diff line number Diff line change
@@ -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("foo"))
assertEquals(0, new Func[Hkt[Id]].select("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
}
}

0 comments on commit 0687c03

Please # to comment.