Skip to content

Commit b71326c

Browse files
committed
Move Quoted and Spliced extractors to TreeInfo
1 parent 02ff72f commit b71326c

File tree

3 files changed

+23
-39
lines changed

3 files changed

+23
-39
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Flags._, Trees._, Types._, Contexts._
77
import Names._, StdNames._, NameOps._, Symbols._
88
import typer.ConstFold
99
import reporting.trace
10+
import dotty.tools.dotc.transform.SymUtils._
1011

1112
import scala.annotation.tailrec
1213

@@ -815,6 +816,28 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
815816
}
816817
}
817818
}
819+
820+
/** Extractors for quotes */
821+
object Quoted {
822+
/** Extracts the content of a quoted tree.
823+
* The result can be the contents of a term or type quote, which
824+
* will return a term or type tree respectively.
825+
*/
826+
def unapply(tree: tpd.Tree)(implicit ctx: Context): Option[tpd.Tree] = tree match {
827+
case tree: GenericApply[Type] if tree.symbol.isQuote => Some(tree.args.head)
828+
case _ => None
829+
}
830+
}
831+
832+
/** Extractors for splices */
833+
object Spliced {
834+
/** Extracts the content of a spliced tree.
835+
* The result can be the contents of a term or type splice, which
836+
* will return a term or type tree respectively.
837+
*/
838+
def unapply(tree: tpd.Select)(implicit ctx: Context): Option[tpd.Tree] =
839+
if (tree.symbol.isSplice) Some(tree.qualifier) else None
840+
}
818841
}
819842

820843
object TreeInfo {

compiler/src/dotty/tools/dotc/core/quoted/Quoted.scala

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

compiler/src/dotty/tools/dotc/core/quoted/Spliced.scala

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

0 commit comments

Comments
 (0)