Skip to content

Commit 5a18ee3

Browse files
pikinier20nicolasstucki
authored andcommitted
Add Type.isTupleType to reflection API
1 parent ce0e25c commit 5a18ee3

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
@@ -1694,6 +1694,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
16941694
val tpNoRefinement = self.dropDependentRefinement
16951695
tpNoRefinement != self
16961696
&& dotc.core.Symbols.defn.isNonRefinedFunction(tpNoRefinement)
1697+
def isTupleType: Boolean =
1698+
dotc.core.Symbols.defn.isTupleType(self)
16971699
def select(sym: Symbol): TypeRepr = self.select(sym)
16981700
def appliedTo(targ: TypeRepr): TypeRepr =
16991701
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
@@ -2473,6 +2473,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
24732473
*/
24742474
def isDependentFunctionType: Boolean
24752475

2476+
/** Is this type a tuple type?
2477+
*
2478+
* @return true if the dealiased type of `self` without refinement is `TupleN[T1, T2, ..., Tn]`
2479+
*/
2480+
def isTupleType: Boolean
2481+
24762482
/** The type <this . sym>, reduced if possible */
24772483
def select(sym: Symbol): TypeRepr
24782484

0 commit comments

Comments
 (0)