Skip to content

Commit 0cbefb4

Browse files
Merge pull request #10201 from dotty-staging/clenup-quote-matcher
Cleanup quote matcher API and docs
2 parents 52be553 + 2817984 commit 0cbefb4

File tree

4 files changed

+11
-127
lines changed

4 files changed

+11
-127
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ object desugar {
919919
def quotedPatternTypeDef(tree: TypeDef)(using Context): TypeDef = {
920920
assert(ctx.mode.is(Mode.QuotedPattern))
921921
if (tree.name.startsWith("$") && !tree.isBackquoted) {
922-
val patternBindHoleAnnot = New(ref(defn.InternalQuotedPatterns_patternTypeAnnot.typeRef)).withSpan(tree.span)
923-
val mods = tree.mods.withAddedAnnotation(patternBindHoleAnnot)
922+
val patternTypeAnnot = New(ref(defn.InternalQuotedPatterns_patternTypeAnnot.typeRef)).withSpan(tree.span)
923+
val mods = tree.mods.withAddedAnnotation(patternTypeAnnot)
924924
tree.withMods(mods)
925925
}
926926
else tree

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ trait QuotesAndSplices {
197197
)
198198

199199
/** Split a typed quoted pattern is split into its type bindings, pattern expression and inner patterns.
200-
* Type definitions with `@patternBindHole` will be inserted in the pattern expression for each type binding.
200+
* Type definitions with `@patternType` will be inserted in the pattern expression for each type binding.
201201
*
202202
* A quote pattern
203203
* ```
@@ -208,7 +208,7 @@ trait QuotesAndSplices {
208208
* (
209209
* Map(<$t>: Symbol -> <$t @ _>: Bind),
210210
* <'{
211-
* @scala.internal.Quoted.patternBindHole type $t
211+
* @scala.internal.Quoted.patternType type $t
212212
* scala.internal.Quoted.patternHole[List[$t]]
213213
* }>: Tree,
214214
* List(<ls: Expr[List[$t]]>: Tree)
@@ -366,7 +366,7 @@ trait QuotesAndSplices {
366366
* ```
367367
*
368368
* For each type splice we will create a new type binding in the pattern match ($t @ _ in this case)
369-
* and a corresponding type in the quoted pattern as a hole (@patternBindHole type $t in this case).
369+
* and a corresponding type in the quoted pattern as a hole (@patternType type $t in this case).
370370
* All these generated types are inserted at the start of the quoted code.
371371
*
372372
* After typing the tree will resemble
@@ -388,7 +388,7 @@ trait QuotesAndSplices {
388388
* (implicit t @ _, ls @ _: Expr[List[$t]]) // from the spliced patterns
389389
* )(
390390
* '{ // Runtime quote Matcher.unapply uses to mach against. Expression directly inside the quoted pattern without the splices
391-
* @scala.internal.Quoted.patternBindHole type $t
391+
* @scala.internal.Quoted.patternType type $t
392392
* scala.internal.Quoted.patternHole[List[$t]]
393393
* },
394394
* true, // If there is at least one type splice. Used to instantiate the context with or without GADT constraints

docs/docs/reference/other-new-features/quoted-pattern-spec.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

library/src-bootstrapped/scala/internal/quoted/Patterns.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,23 @@ import scala.annotation.{Annotation, compileTimeOnly}
55
object Patterns {
66

77
/** A splice in a quoted pattern is desugared by the compiler into a call to this method */
8-
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternHole`")
8+
@compileTimeOnly("Illegal reference to `scala.internal.quoted.Patterns.patternHole`")
99
def patternHole[T]: T = ???
1010

11-
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternHigherOrderHole`")
11+
@compileTimeOnly("Illegal reference to `scala.internal.quoted.Patterns.patternHigherOrderHole`")
1212
/** A higher order splice in a quoted pattern is desugared by the compiler into a call to this method */
1313
def patternHigherOrderHole[U](pat: Any, args: Any*): U = ???
1414

15-
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.higherOrderHole`")
15+
@compileTimeOnly("Illegal reference to `scala.internal.quoted.Patterns.higherOrderHole`")
1616
/** A higher order splice in a quoted pattern is desugared by the compiler into a call to this method */
1717
def higherOrderHole[U](args: Any*): U = ???
1818

19-
// TODO remove
20-
/** A splice of a name in a quoted pattern is desugared by wrapping getting this annotation */
21-
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternBindHole`")
22-
class patternBindHole extends Annotation
23-
2419
/** A splice of a name in a quoted pattern is that marks the definition of a type splice */
25-
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternType`")
20+
@compileTimeOnly("Illegal reference to `scala.internal.quoted.Patterns.patternType`")
2621
class patternType extends Annotation
2722

2823
/** A type pattern that must be aproximated from above */
29-
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.fromAbove`")
24+
@compileTimeOnly("Illegal reference to `scala.internal.quoted.Patterns.fromAbove`")
3025
class fromAbove extends Annotation
3126

3227
}

0 commit comments

Comments
 (0)