1+ class Foo {
2+
3+ type E [X ]
4+
5+ def i : Int = ???
6+ def e : E [Int ] = ???
7+
8+ // Transforms `(T1, ... Tn)` into `(E[T1], ..., E[Tn])`
9+ type F [T <: Tuple ] <: Tuple = T match {
10+ case EmptyTuple => EmptyTuple
11+ case h *: t => E [h] *: F [t]
12+ }
13+
14+ def foo1 [Args <: Tuple ](args : Args , args2 : F [Args ]): Unit = ()
15+
16+ foo1((i, i), (e, e)) // fails
17+ foo1((i, i), (e, e): F [(Int , Int )]) // fails
18+
19+ }
20+
21+ class Foo2 {
22+
23+ type E [X ]
24+
25+ def i : Int = ???
26+ def e : E [Int ] = ???
27+
28+ // Transforms `(T1, ... Tn)` into `(E[T1], ..., E[Tn])`
29+ type F [T <: Tuple ] <: Tuple = T match {
30+ case EmptyTuple => EmptyTuple
31+ case h *: t => E [h] *: F [t]
32+ }
33+
34+ def foo2 [Args <: Tuple , Args2 >: F [Args ] <: F [Args ]](args : Args , args2 : Args2 ): Unit = ()
35+
36+ foo2((i, i), (e, e)) // fails
37+
38+ // all these work
39+ foo2[(Int , Int ), F [(Int , Int )]]((i, i), (e, e))
40+ foo2[(Int , Int ), F [(Int , Int )]]((i, i), (e, e))
41+ foo2[(Int , Int ), F [Int *: Int *: EmptyTuple ]]((i, i), (e, e))
42+ foo2[(Int , Int ), (E [Int ], E [Int ])]((i, i), (e, e))
43+ foo2[(Int , Int ), E [Int ] *: E [Int ] *: EmptyTuple ]((i, i), (e, e))
44+
45+ }
0 commit comments