-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is also fixed by the parent commit. [Cherry-picked eb18e53][modified]
- Loading branch information
1 parent
76ae989
commit 6f194ed
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ i6505.scala | |
i15158.scala | ||
i15155.scala | ||
i15827.scala | ||
i18211.scala | ||
|
||
# Opaque type | ||
i5720.scala | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import scala.compiletime.ops.int.* | ||
|
||
type AnyInt[A <: Int] <: Int = A match { | ||
case _ => A | ||
} | ||
|
||
type IndexOf[A, T <: Tuple] <: Int = T match { | ||
case EmptyTuple => -1 | ||
case A *: t => 0 | ||
case _ *: t => | ||
IndexOf[A, t] match { | ||
case -1 => -1 | ||
case AnyInt[a] => S[a] | ||
} | ||
} | ||
|
||
type Indexes[A, T <: Tuple] | ||
object Indexes { | ||
given of[A, T <: Tuple](using IndexOf[A, T] >= 0 =:= true)(using | ||
index: ValueOf[IndexOf[A, T]], | ||
next: Indexes[A, Tuple.Drop[T, S[IndexOf[A, T]]]] | ||
): Indexes[A, T] = ??? | ||
|
||
given empty[A, T <: Tuple](using IndexOf[A, T] =:= -1): Indexes[A, T] = ??? | ||
} | ||
|
||
class GetAll[A]: | ||
def apply[T <: Tuple](t: T)(using indexes: Indexes[A, T]): List[A] = ??? | ||
|
||
def getAll[A]: GetAll[A] = new GetAll[A] | ||
|
||
def test = | ||
// the code here is trying to get all values from a tuple that has type [X] as a list | ||
|
||
// this works if there are only two strings in the tuple | ||
getAll[String](("str1", 1, "str2", false)) | ||
|
||
//but this not compiles if there are more than two strings in the tuple | ||
getAll[String](("str1", 1, "str2", false, "str3")) |