-
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.
- Loading branch information
1 parent
c328d74
commit e765d5e
Showing
2 changed files
with
46 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import scala.quoted.* | ||
|
||
inline def isTupleN[T]: Boolean = ${ isTupleNImpl[T] } | ||
|
||
private def isTupleNImpl[T: Type](using Quotes): Expr[Boolean] = { | ||
import quotes.reflect.* | ||
Expr(TypeRepr.of[T].isTupleN) | ||
} |
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,38 @@ | ||
@main def Test = { | ||
assert(isTupleN[Tuple1[Int]]) | ||
assert(isTupleN[(Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
assert(isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) | ||
|
||
type Tup = (Int, Int) | ||
assert(isTupleN[Tup]) | ||
|
||
assert(!isTupleN[(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)]) // No tuple 23 | ||
assert(!isTupleN[Tuple]) | ||
assert(!isTupleN[EmptyTuple]) | ||
assert(!isTupleN[NonEmptyTuple]) | ||
assert(!isTupleN[Int *: Tuple]) | ||
|
||
assert(!isTupleN[Any]) | ||
assert(!isTupleN[Int]) | ||
assert(!isTupleN[Object]) | ||
assert(!isTupleN[Nothing]) | ||
} |