Skip to content

Cleanup quote matcher API and docs #10201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@ object desugar {
def quotedPatternTypeDef(tree: TypeDef)(using Context): TypeDef = {
assert(ctx.mode.is(Mode.QuotedPattern))
if (tree.name.startsWith("$") && !tree.isBackquoted) {
val patternBindHoleAnnot = New(ref(defn.InternalQuotedPatterns_patternTypeAnnot.typeRef)).withSpan(tree.span)
val mods = tree.mods.withAddedAnnotation(patternBindHoleAnnot)
val patternTypeAnnot = New(ref(defn.InternalQuotedPatterns_patternTypeAnnot.typeRef)).withSpan(tree.span)
val mods = tree.mods.withAddedAnnotation(patternTypeAnnot)
tree.withMods(mods)
}
else tree
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ trait QuotesAndSplices {
)

/** Split a typed quoted pattern is split into its type bindings, pattern expression and inner patterns.
* Type definitions with `@patternBindHole` will be inserted in the pattern expression for each type binding.
* Type definitions with `@patternType` will be inserted in the pattern expression for each type binding.
*
* A quote pattern
* ```
Expand All @@ -208,7 +208,7 @@ trait QuotesAndSplices {
* (
* Map(<$t>: Symbol -> <$t @ _>: Bind),
* <'{
* @scala.internal.Quoted.patternBindHole type $t
* @scala.internal.Quoted.patternType type $t
* scala.internal.Quoted.patternHole[List[$t]]
* }>: Tree,
* List(<ls: Expr[List[$t]]>: Tree)
Expand Down Expand Up @@ -366,7 +366,7 @@ trait QuotesAndSplices {
* ```
*
* For each type splice we will create a new type binding in the pattern match ($t @ _ in this case)
* and a corresponding type in the quoted pattern as a hole (@patternBindHole type $t in this case).
* and a corresponding type in the quoted pattern as a hole (@patternType type $t in this case).
* All these generated types are inserted at the start of the quoted code.
*
* After typing the tree will resemble
Expand All @@ -388,7 +388,7 @@ trait QuotesAndSplices {
* (implicit t @ _, ls @ _: Expr[List[$t]]) // from the spliced patterns
* )(
* '{ // Runtime quote Matcher.unapply uses to mach against. Expression directly inside the quoted pattern without the splices
* @scala.internal.Quoted.patternBindHole type $t
* @scala.internal.Quoted.patternType type $t
* scala.internal.Quoted.patternHole[List[$t]]
* },
* true, // If there is at least one type splice. Used to instantiate the context with or without GADT constraints
Expand Down
111 changes: 0 additions & 111 deletions docs/docs/reference/other-new-features/quoted-pattern-spec.md

This file was deleted.

15 changes: 5 additions & 10 deletions library/src-bootstrapped/scala/internal/quoted/Patterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,23 @@ import scala.annotation.{Annotation, compileTimeOnly}
object Patterns {

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

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

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

// TODO remove
/** A splice of a name in a quoted pattern is desugared by wrapping getting this annotation */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternBindHole`")
class patternBindHole extends Annotation

/** A splice of a name in a quoted pattern is that marks the definition of a type splice */
@compileTimeOnly("Illegal reference to `scala.internal.quoted.CompileTime.patternType`")
@compileTimeOnly("Illegal reference to `scala.internal.quoted.Patterns.patternType`")
class patternType extends Annotation

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

}

This file was deleted.