Skip to content

Commit f867da2

Browse files
committed
Test case for 8825
1 parent f24fffa commit f867da2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/pos/i8825.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
sealed trait Nat
2+
case class Succ[N <: Nat](n: N) extends Nat
3+
case object Zero extends Nat
4+
type Zero = Zero.type
5+
type One = Succ[Zero]
6+
7+
sealed trait HList
8+
case class HCons[+H, +T <: HList](head: H, tail: T) extends HList
9+
case object HNil extends HList
10+
type HNil = HNil.type
11+
12+
trait Length[L <: HList] {
13+
type Out <: Nat
14+
}
15+
object Length {
16+
type Aux[L <: HList, Out0 <: Nat] = Length[L] { type Out = Out0 }
17+
def instance[L <: HList, Out0 <: Nat]: Aux[L, Out0] = new Length[L] { type Out = Out0 }
18+
19+
given hnilLength as Aux[HNil, Zero] = instance
20+
given hconsLength[H, T <: HList] (using length: Length[T]) as Aux[HCons[H, T], Succ[length.Out]] = instance // (*)
21+
//given hconsLength[H, T <: HList, N <: Nat] (using length: Aux[T, N]) as Aux[HCons[H, T], Succ[N]] = instance // (**)
22+
}
23+
24+
val test = summon[Length.Aux[HCons[Int, HNil], One]]

0 commit comments

Comments
 (0)