QuotePatterns

dotty.tools.dotc.quoted.QuotePatterns
object QuotePatterns

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def checkPattern(quotePattern: QuotePattern)(using Context): Unit

Check for restricted patterns

Check for restricted patterns

Attributes

def decode(tree: UnApply)(using Context): QuotePattern

Decodes an encoded pattern into a QuotePattern.

Decodes an encoded pattern into a QuotePattern.

See the documentation of encode, this does the opposite transformation.

Attributes

def encode(quotePattern: QuotePattern)(using Context): UnApply

Encode the quote pattern into an unapply that the pattern matcher can handle.

Encode the quote pattern into an unapply that the pattern matcher can handle.

A quote pattern

'{
  // type variables (QuotePattern.bindings Bind list)
  type t1 >: l1 <: b1
  ...
  type tn >: ln <: bn
  // pattern (QuotePattern.body)
  ... $x1: T1 ... ${ F(x2) }: T2 ... $f(a1: A1, ..., an: An): T3 ...
} // (using quotes) (QuotePattern.quotes)

is transformed into the pattern

quotes
  .asInstanceOf[QuoteMatching] // scala.quoted.runtime.QuoteMatching
  .ExprMatch // or TypeMatch
  .unapply[
    KCons[t1 >: l1 <: b1, ...KCons[tn >: ln <: bn, KNil]...], // scala.quoted.runtime.{KCons, KNil}
    (T1, T2, (A1, ..., An) => T3, ...)
  ](
    '{
      type t1' >: l1' <: b1'
      ...
      type tn' >: ln' <: bn'
      // scala.quoted.runtime.Patterns.{patternHole, higherOrderHole}
      ... $patternHole[T1] ... $patternHole[T2] ... $higherOrderHole[T3](a1, ..., an) ...
     },
     quotes
  )

 Here ti' is a `TypeDef` that represents `ti` in the (pickled) pattern body. The type bounds
 `>: l1' <: b1` of `ti'` are the same as the type bounds `>: l1 <: b1` replacing all references
 to `tj` with `tj'`.

Attributes