Skip to content

Commit eb18e53

Browse files
committed
Fix #18211: Add regression test.
This is also fixed by the parent commit.
1 parent ad29ce8 commit eb18e53

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

compiler/test/dotc/pos-test-pickling.blacklist

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ i15827.scala
5656
i17149.scala
5757
tuple-fold.scala
5858
mt-redux-norm.perspective.scala
59+
i18211.scala
5960

6061
# Opaque type
6162
i5720.scala

tests/pos/i18211.scala

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import scala.compiletime.ops.int.*
2+
3+
type AnyInt[A <: Int] <: Int = A match {
4+
case _ => A
5+
}
6+
7+
type IndexOf[A, T <: Tuple] <: Int = T match {
8+
case EmptyTuple => -1
9+
case A *: t => 0
10+
case _ *: t =>
11+
IndexOf[A, t] match {
12+
case -1 => -1
13+
case AnyInt[a] => S[a]
14+
}
15+
}
16+
17+
type Indexes[A, T <: Tuple]
18+
object Indexes {
19+
given of[A, T <: Tuple](using IndexOf[A, T] >= 0 =:= true)(using
20+
index: ValueOf[IndexOf[A, T]],
21+
next: Indexes[A, Tuple.Drop[T, S[IndexOf[A, T]]]]
22+
): Indexes[A, T] = ???
23+
24+
given empty[A, T <: Tuple](using IndexOf[A, T] =:= -1): Indexes[A, T] = ???
25+
}
26+
27+
class GetAll[A]:
28+
def apply[T <: Tuple](t: T)(using indexes: Indexes[A, T]): List[A] = ???
29+
30+
def getAll[A]: GetAll[A] = new GetAll[A]
31+
32+
def test =
33+
// the code here is trying to get all values from a tuple that has type [X] as a list
34+
35+
// this works if there are only two strings in the tuple
36+
getAll[String](("str1", 1, "str2", false))
37+
38+
//but this not compiles if there are more than two strings in the tuple
39+
getAll[String](("str1", 1, "str2", false, "str3"))

0 commit comments

Comments
 (0)