Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add missing asInstanceOf call #984

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}