@@ -1622,7 +1622,30 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
16221622 end extension
16231623 end ReturnMethods
16241624
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+ */
16261649 type Repeated <: Term
16271650
16281651 /** `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 =>
16331656
16341657 /** Methods of the module object `val Repeated` */
16351658 trait RepeatedModule { this : Repeated .type =>
1659+ /** Create a literal sequence of elements */
16361660 def apply (elems : List [Term ], tpt : TypeTree ): Repeated
1661+ /** Copy a literal sequence of elements */
16371662 def copy (original : Tree )(elems : List [Term ], tpt : TypeTree ): Repeated
1663+ /** Matches a literal sequence of elements */
16381664 def unapply (x : Repeated ): (List [Term ], TypeTree )
16391665 }
16401666
@@ -4314,6 +4340,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
43144340
43154341 /** A dummy class symbol that is used to indicate repeated parameters
43164342 * compiled by the Scala compiler.
4343+ *
4344+ * @see Repeated
43174345 */
43184346 def RepeatedParamClass : Symbol
43194347
0 commit comments