Skip to content

Commit 302f972

Browse files
pikinier20nicolasstucki
authored andcommitted
Add Type.isTupleType to reflection API
1 parent 216b76c commit 302f972

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
17381738
val tpNoRefinement = self.dropDependentRefinement
17391739
tpNoRefinement != self
17401740
&& dotc.core.Symbols.defn.isNonRefinedFunction(tpNoRefinement)
1741+
def isTupleType: Boolean =
1742+
dotc.core.Symbols.defn.isTupleType(self)
17411743
def select(sym: Symbol): TypeRepr = self.select(sym)
17421744
def appliedTo(targ: TypeRepr): TypeRepr =
17431745
dotc.core.Types.decorateTypeApplications(self).appliedTo(targ)

library/src/scala/quoted/Quotes.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
25262526
*/
25272527
def isDependentFunctionType: Boolean
25282528

2529+
/** Is this type a tuple type?
2530+
*
2531+
* @return true if the dealiased type of `self` without refinement is `TupleN[T1, T2, ..., Tn]`
2532+
*/
2533+
def isTupleType: Boolean
2534+
25292535
/** The type <this . sym>, reduced if possible */
25302536
def select(sym: Symbol): TypeRepr
25312537

0 commit comments

Comments
 (0)