-
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.
Backport "Approximate MatchTypes with lub of case bodies, if non-recu…
…rsive" to LTS (#20972) Backports #19761 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
6 changed files
with
58 additions
and
9 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
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
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,7 @@ | ||
import compiletime.ops.int.* | ||
|
||
type Drop[T <: Tuple, N <: Int] <: Tuple = N match | ||
case 0 => T | ||
case S[n1] => T match | ||
case EmptyTuple => EmptyTuple | ||
case x *: xs => Drop[xs, n1] |
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,7 @@ | ||
import compiletime.ops.int.* | ||
|
||
type Elem[T <: Tuple, I <: Int] = T match | ||
case h *: tail => | ||
I match | ||
case 0 => h | ||
case S[j] => Elem[tail, j] |
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,11 @@ | ||
import scala.util.NotGiven | ||
|
||
type HasName1 = [n] =>> [x] =>> x match { | ||
case n => true | ||
case _ => false | ||
} | ||
@main def Test = { | ||
summon[HasName1["foo"]["foo"] =:= true] | ||
summon[NotGiven[HasName1["foo"]["bar"] =:= true]] | ||
summon[Tuple.Filter[(1, "foo", 2, "bar"), HasName1["foo"]] =:= Tuple1["foo"]] // error | ||
} |
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