Skip to content

Commit 1d19f17

Browse files
test: add in a regression test for #11706 (#17499)
[skip community_build] closes #11706
2 parents 4470d4c + e657ac8 commit 1d19f17

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/run/i11706.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
3

tests/run/i11706.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// https://github.com/lampepfl/dotty/issues/11706
2+
import scala.compiletime.erasedValue
3+
4+
object Obj:
5+
6+
inline def length[Tuple]: Int = loop[Tuple]
7+
8+
private inline def loop[Tuple]: Int =
9+
inline erasedValue[Tuple] match
10+
case _: EmptyTuple => 0
11+
case _: (head *: tail) => 1 + loop[tail]
12+
13+
end Obj
14+
15+
// Same code, but in a trait instead of an object
16+
trait Trait:
17+
18+
inline def length[Tuple]: Int = loop[Tuple]
19+
20+
private inline final def loop[Tuple]: Int =
21+
inline erasedValue[Tuple] match
22+
case _: EmptyTuple => 0
23+
case _: (head *: tail) => 1 + loop[tail]
24+
25+
end Trait
26+
27+
@main def Test() =
28+
println(Obj.length[(Int, Int, String)]) // OK
29+
new Trait:
30+
println(length[(Int, Int, String)])

0 commit comments

Comments
 (0)