11package scala .internal .quoted
22
33import scala .annotation .internal .sharable
4+ import scala .annotation .{Annotation , compileTimeOnly }
45
56import scala .quoted ._
67
@@ -94,7 +95,36 @@ import scala.quoted._
9495 *
9596 * ```
9697 */
97- private [quoted] object Matcher {
98+ object Matcher {
99+
100+ // TODO move to internal.Quoted.Matcher
101+ /** A splice in a quoted pattern is desugared by the compiler into a call to this method */
102+ @ compileTimeOnly(" Illegal reference to `scala.internal.quoted.CompileTime.patternHole`" )
103+ def patternHole [T ]: T = ???
104+
105+ @ compileTimeOnly(" Illegal reference to `scala.internal.quoted.CompileTime.patternHigherOrderHole`" )
106+ /** A higher order splice in a quoted pattern is desugared by the compiler into a call to this method */
107+ def patternHigherOrderHole [U ](pat : Any , args : Any * ): U = ???
108+
109+ // TODO move to internal.Quoted.Matcher
110+ @ compileTimeOnly(" Illegal reference to `scala.internal.quoted.CompileTime.higherOrderHole`" )
111+ /** A higher order splice in a quoted pattern is desugared by the compiler into a call to this method */
112+ def higherOrderHole [U ](args : Any * ): U = ???
113+
114+ // TODO remove
115+ /** A splice of a name in a quoted pattern is desugared by wrapping getting this annotation */
116+ @ compileTimeOnly(" Illegal reference to `scala.internal.quoted.CompileTime.patternBindHole`" )
117+ class patternBindHole extends Annotation
118+
119+ // TODO move to internal.Quoted.Matcher
120+ /** A splice of a name in a quoted pattern is that marks the definition of a type splice */
121+ @ compileTimeOnly(" Illegal reference to `scala.internal.quoted.CompileTime.patternType`" )
122+ class patternType extends Annotation
123+
124+ // TODO move to internal.Quoted.Matcher
125+ /** A type pattern that must be aproximated from above */
126+ @ compileTimeOnly(" Illegal reference to `scala.internal.quoted.CompileTime.fromAbove`" )
127+ class fromAbove extends Annotation
98128
99129 class QuoteMatcher [QCtx <: QuoteContext & Singleton ](using val qctx : QCtx ) {
100130 // TODO improve performance
@@ -164,13 +194,13 @@ private[quoted] object Matcher {
164194 private def hasFromAboveAnnotation (sym : Symbol ) = sym.annots.exists(isFromAboveAnnotation)
165195
166196 private def isPatternTypeAnnotation (tree : Tree ): Boolean = tree match {
167- case New (tpt) => tpt.symbol == internal.Definitions_InternalQuoted_patternTypeAnnot
168- case annot => annot.symbol.owner == internal.Definitions_InternalQuoted_patternTypeAnnot
197+ case New (tpt) => tpt.symbol == internal.Definitions_InternalQuotedMatcher_patternTypeAnnot
198+ case annot => annot.symbol.owner == internal.Definitions_InternalQuotedMatcher_patternTypeAnnot
169199 }
170200
171201 private def isFromAboveAnnotation (tree : Tree ): Boolean = tree match {
172- case New (tpt) => tpt.symbol == internal.Definitions_InternalQuoted_fromAboveAnnot
173- case annot => annot.symbol.owner == internal.Definitions_InternalQuoted_fromAboveAnnot
202+ case New (tpt) => tpt.symbol == internal.Definitions_InternalQuotedMatcher_fromAboveAnnot
203+ case annot => annot.symbol.owner == internal.Definitions_InternalQuotedMatcher_fromAboveAnnot
174204 }
175205
176206 /** Check that all trees match with `mtch` and concatenate the results with &&& */
@@ -226,15 +256,15 @@ private[quoted] object Matcher {
226256 /* Term hole */
227257 // Match a scala.internal.Quoted.patternHole typed as a repeated argument and return the scrutinee tree
228258 case (scrutinee @ Typed (s, tpt1), Typed (TypeApply (patternHole, tpt :: Nil ), tpt2))
229- if patternHole.symbol == internal.Definitions_InternalQuoted_patternHole &&
259+ if patternHole.symbol == internal.Definitions_InternalQuotedMatcher_patternHole &&
230260 s.tpe <:< tpt.tpe &&
231261 tpt2.tpe.derivesFrom(defn.RepeatedParamClass ) =>
232262 matched(scrutinee.seal)
233263
234264 /* Term hole */
235265 // Match a scala.internal.Quoted.patternHole and return the scrutinee tree
236266 case (ClosedPatternTerm (scrutinee), TypeApply (patternHole, tpt :: Nil ))
237- if patternHole.symbol == internal.Definitions_InternalQuoted_patternHole &&
267+ if patternHole.symbol == internal.Definitions_InternalQuotedMatcher_patternHole &&
238268 scrutinee.tpe <:< tpt.tpe =>
239269 matched(scrutinee.seal)
240270
@@ -243,7 +273,7 @@ private[quoted] object Matcher {
243273 // DEPRECATED: replaced with `higherOrderHole`
244274 // TODO: remove case
245275 case (scrutinee, pattern @ Apply (Select (TypeApply (patternHole, List (Inferred ())), " apply" ), args0 @ IdentArgs (args)))
246- if patternHole.symbol == internal.Definitions_InternalQuoted_patternHole =>
276+ if patternHole.symbol == internal.Definitions_InternalQuotedMatcher_patternHole =>
247277 def bodyFn (lambdaArgs : List [Tree ]): Tree = {
248278 val argsMap = args.map(_.symbol).zip(lambdaArgs.asInstanceOf [List [Term ]]).toMap
249279 new TreeMap {
@@ -262,7 +292,7 @@ private[quoted] object Matcher {
262292 /* Higher order term hole */
263293 // Matches an open term and wraps it into a lambda that provides the free variables
264294 case (scrutinee, pattern @ Apply (TypeApply (Ident (" higherOrderHole" ), List (Inferred ())), Repeated (args, _) :: Nil ))
265- if pattern.symbol == internal.Definitions_InternalQuoted_higherOrderHole =>
295+ if pattern.symbol == internal.Definitions_InternalQuotedMatcher_higherOrderHole =>
266296
267297 def bodyFn (lambdaArgs : List [Tree ]): Tree = {
268298 val argsMap = args.map(_.symbol).zip(lambdaArgs.asInstanceOf [List [Term ]]).toMap
0 commit comments