Open alexarchambault opened 8 years ago
@milessabin Does this ring a bell to you? This looks quite similar to https://github.com/alexarchambault/scalacheck-shapeless/issues/7#issuecomment-103904848, although removing arbContainer2
from scalacheck-shapeless doesn't address the issue here (one just gets "cannot find implicit value..." then).
Unlike https://github.com/alexarchambault/scalacheck-shapeless/issues/7, the problem only appears when singleton types are involved.
No, I've not seen this before. It might be my fault, but I'm tempted to call this a compiler bug. Here's something else which works,
scala> type One = Witness.`1`.T
defined type alias One
scala> test((1: One) :: HNil)
res7: org.scalacheck.Arbitrary[shapeless.::[One,shapeless.HNil]] = org.scalacheck.ArbitraryLowPriority$$anon$1@595812b9
Also note,
scala> 1.narrow
res8: Int(1) = 1
scala> (1.narrow: One)
res9: One = 1
And again,
scala> def typed[T](t: T)(implicit ev: T =:= (One :: HNil)) = {}
typed: [T](t: T)(implicit ev: =:=[T,shapeless.::[One,shapeless.HNil]])Unit
scala> typed(1 :: HNil)
<console>:26: error: Cannot prove that shapeless.::[Int,shapeless.HNil] =:= shapeless.::[One,shapeless.HNil].
typed(1 :: HNil)
^
scala> typed(1.narrow :: HNil)
scala>
Reported by @raulraja on the gitter of shapeless (https://gitter.im/milessabin/shapeless?at=56fcf50fbbffcc665faad6e5)
Surprisingly, explicitly specifying the type parameter of
test
makes this work again,