@@ -609,11 +609,13 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
609
609
end extension
610
610
end NamedArgMethods
611
611
612
- type Apply = tpd.Apply
612
+ type Apply = tpd.Apply | tpd. Quote | tpd. Splice
613
613
614
614
object ApplyTypeTest extends TypeTest [Tree , Apply ]:
615
615
def unapply (x : Tree ): Option [Apply & x.type ] = x match
616
616
case x : (tpd.Apply & x.type ) => Some (x)
617
+ case x : (tpd.Quote & x.type ) => Some (x) // TODO expose Quote AST in Quotes
618
+ case x : (tpd.Splice & x.type ) => Some (x) // TODO expose Splice AST in Quotes
617
619
case _ => None
618
620
end ApplyTypeTest
619
621
@@ -630,8 +632,23 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
630
632
631
633
given ApplyMethods : ApplyMethods with
632
634
extension (self : Apply )
633
- def fun : Term = self.fun
634
- def args : List [Term ] = self.args
635
+ def fun : Term = self match
636
+ case self : tpd.Apply => self.fun
637
+ case self : tpd.Quote => // TODO expose Quote AST in Quotes
638
+ import dotty .tools .dotc .ast .tpd .TreeOps
639
+ tpd.ref(dotc.core.Symbols .defn.QuotedRuntime_exprQuote )
640
+ .appliedToTypeTree(self.tpt)
641
+ .withSpan(self.span)
642
+ case self : tpd.Splice => // TODO expose Splice AST in Quotes
643
+ import dotty .tools .dotc .ast .tpd .TreeOps
644
+ tpd.ref(dotc.core.Symbols .defn.QuotedRuntime_exprSplice )
645
+ .appliedToTypeTree(self.tpt)
646
+ .withSpan(self.span)
647
+
648
+ def args : List [Term ] = self match
649
+ case self : tpd.Apply => self.args
650
+ case self : tpd.Quote => List (self.expr) // TODO expose Quote AST in Quotes
651
+ case self : tpd.Splice => List (self.expr) // TODO expose Splice AST in Quotes
635
652
end extension
636
653
end ApplyMethods
637
654
0 commit comments