@@ -1622,7 +1622,30 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
1622
1622
end extension
1623
1623
end ReturnMethods
1624
1624
1625
- /** Tree representing a variable argument list in the source code */
1625
+ /** Tree representing a variable argument list in the source code.
1626
+ *
1627
+ * This tree is used to encode varargs terms. The Repeated encapsulates
1628
+ * the sequence of the elements but needs to be wrapped in a
1629
+ * `scala.<repeated>[T]` (see `defn.RepeatedParamClass`). For example the
1630
+ * arguments `1, 2` of `List.apply(1, 2)` can be represented as follows:
1631
+ *
1632
+ *
1633
+ * ```scala
1634
+ * //{
1635
+ * import scala.quoted._
1636
+ * def inQuotes(using Quotes) = {
1637
+ * val q: Quotes = summon[Quotes]
1638
+ * import q.reflect._
1639
+ * //}
1640
+ * val intArgs = List(Literal(Constant(1)), Literal(Constant(2)))
1641
+ * Typed(
1642
+ * Repeated(intArgs, TypeTree.of[Int]),
1643
+ * Inferred(defn.RepeatedParamClass.typeRef.appliedTo(TypeRepr.of[Int]))
1644
+ * //{
1645
+ * }
1646
+ * //}
1647
+ * ```
1648
+ */
1626
1649
type Repeated <: Term
1627
1650
1628
1651
/** `TypeTest` that allows testing at runtime in a pattern match if a `Tree` is a `Repeated` */
@@ -1633,8 +1656,11 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
1633
1656
1634
1657
/** Methods of the module object `val Repeated` */
1635
1658
trait RepeatedModule { this : Repeated .type =>
1659
+ /** Create a literal sequence of elements */
1636
1660
def apply (elems : List [Term ], tpt : TypeTree ): Repeated
1661
+ /** Copy a literal sequence of elements */
1637
1662
def copy (original : Tree )(elems : List [Term ], tpt : TypeTree ): Repeated
1663
+ /** Matches a literal sequence of elements */
1638
1664
def unapply (x : Repeated ): (List [Term ], TypeTree )
1639
1665
}
1640
1666
@@ -4314,6 +4340,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
4314
4340
4315
4341
/** A dummy class symbol that is used to indicate repeated parameters
4316
4342
* compiled by the Scala compiler.
4343
+ *
4344
+ * @see Repeated
4317
4345
*/
4318
4346
def RepeatedParamClass : Symbol
4319
4347
0 commit comments