Skip to content

Commit 8ec5fb2

Browse files
committed
Move all macro related classes to dotty.tools.dotc.quoted.[reflect]
1 parent 0246f72 commit 8ec5fb2

19 files changed

+48
-48
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ import scala.annotation.{switch, tailrec}
3737
import scala.collection.mutable.ListBuffer
3838
import scala.collection.mutable
3939
import config.Printers.pickling
40-
import core.quoted.PickledQuotes
41-
import dotty.tools.dotc.quoted.QuoteContext
40+
import quoted.PickledQuotes
4241

4342
import dotty.tools.tasty.TastyFormat._
4443

compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import scala.io.Codec
88
import dotty.tools.dotc.core.Contexts._
99
import dotty.tools.dotc.core.Phases.Phase
1010
import dotty.tools.dotc.core.tasty.TastyPrinter
11-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
11+
import dotty.tools.dotc.quoted.reflect.ReflectionImpl
1212
import dotty.tools.io.File
1313

1414
/** Phase that prints the trees in all loaded compilation units.

compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dotty.tools.dotc.core.Contexts._
66
import dotty.tools.dotc.core._
77
import dotty.tools.dotc.core.tasty.TastyHTMLPrinter
88
import dotty.tools.dotc.reporting._
9-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
9+
import dotty.tools.dotc.quoted.reflect.ReflectionImpl
1010

1111
/**
1212
* Decompiler to be used with IDEs

compiler/src/dotty/tools/dotc/tastyreflect/MacroExpansion.scala renamed to compiler/src/dotty/tools/dotc/quoted/MacroExpansion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dotty.tools.dotc.tastyreflect
1+
package dotty.tools.dotc.quoted
22

33
import dotty.tools.dotc.ast.tpd
44
import dotty.tools.dotc.core._

compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala renamed to compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dotty.tools.dotc.core.quoted
1+
package dotty.tools.dotc.quoted
22

33
import dotty.tools.dotc.ast.Trees._
44
import dotty.tools.dotc.ast.{TreeTypeMap, tpd}
@@ -15,14 +15,14 @@ import dotty.tools.dotc.core.tasty.TreePickler.Hole
1515
import dotty.tools.dotc.core.tasty.{ PositionPickler, TastyPickler, TastyPrinter }
1616
import dotty.tools.dotc.core.tasty.DottyUnpickler
1717
import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode
18-
import dotty.tools.dotc.quoted.QuoteContext
19-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
18+
import dotty.tools.dotc.quoted.reflect.ReflectionImpl
2019

2120
import dotty.tools.tasty.TastyString
2221

2322
import scala.reflect.ClassTag
2423

2524
import scala.internal.quoted.Unpickler._
25+
import scala.quoted.QuoteContext
2626

2727
object PickledQuotes {
2828
import tpd._
@@ -39,14 +39,14 @@ object PickledQuotes {
3939
/** Transform the expression into its fully spliced Tree */
4040
def quotedExprToTree[T](expr: quoted.Expr[T])(using Context): Tree = {
4141
val expr1 = expr.asInstanceOf[scala.internal.quoted.Expr[Tree]]
42-
QuoteContext.checkScopeId(expr1.scopeId)
42+
QuoteContextImpl.checkScopeId(expr1.scopeId)
4343
healOwner(expr1.tree)
4444
}
4545

4646
/** Transform the expression into its fully spliced TypeTree */
4747
def quotedTypeToTree(tpe: quoted.Type[?])(using Context): Tree = {
4848
val tpe1 = tpe.asInstanceOf[scala.internal.quoted.Type[Tree]]
49-
QuoteContext.checkScopeId(tpe1.scopeId)
49+
QuoteContextImpl.checkScopeId(tpe1.scopeId)
5050
healOwner(tpe1.typeTree)
5151
}
5252

@@ -76,12 +76,12 @@ object PickledQuotes {
7676
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {
7777
case Hole(isTerm, idx, args) =>
7878
val reifiedArgs = args.map { arg =>
79-
if (arg.isTerm) (using qctx: scala.quoted.QuoteContext) => new scala.internal.quoted.Expr(arg, QuoteContext.scopeId)
80-
else new scala.internal.quoted.Type(arg, QuoteContext.scopeId)
79+
if (arg.isTerm) (using qctx: QuoteContext) => new scala.internal.quoted.Expr(arg, QuoteContextImpl.scopeId)
80+
else new scala.internal.quoted.Type(arg, QuoteContextImpl.scopeId)
8181
}
8282
if isTerm then
83-
val splice1 = splices(idx).asInstanceOf[Seq[Any] => scala.quoted.QuoteContext ?=> quoted.Expr[?]]
84-
val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContext())
83+
val splice1 = splices(idx).asInstanceOf[Seq[Any] => QuoteContext ?=> quoted.Expr[?]]
84+
val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContextImpl())
8585
val filled = PickledQuotes.quotedExprToTree(quotedExpr)
8686

8787
// We need to make sure a hole is created with the source file of the surrounding context, even if
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package dotty.tools.dotc.quoted
22

33
import dotty.tools.dotc.core.Contexts._
4-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
54

6-
object QuoteContext {
5+
import scala.quoted.QuoteContext
76

8-
def apply()(using Context): scala.quoted.QuoteContext =
9-
new QuoteContext(ReflectionImpl(summon[Context]))
7+
object QuoteContextImpl {
8+
9+
def apply()(using Context): QuoteContext =
10+
new QuoteContextImpl(reflect.ReflectionImpl(ctx))
1011

1112
type ScopeId = Int
1213

@@ -17,7 +18,7 @@ object QuoteContext {
1718
// TODO Explore more fine grained scope ids.
1819
// This id can only differentiate scope extrusion from one compiler instance to another.
1920
private[dotty] def scopeId(using Context): ScopeId =
20-
summon[Context].outersIterator.toList.last.hashCode()
21+
ctx.outersIterator.toList.last.hashCode()
2122
}
2223

23-
class QuoteContext(val tasty: scala.tasty.Reflection) extends scala.quoted.QuoteContext
24+
class QuoteContextImpl(val tasty: scala.tasty.Reflection) extends QuoteContext

compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala renamed to compiler/src/dotty/tools/dotc/quoted/reflect/FromSymbol.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package dotty.tools.dotc.tastyreflect
1+
package dotty.tools.dotc.quoted
2+
package reflect
23

34
import dotty.tools.dotc.ast.tpd
45
import dotty.tools.dotc.ast.untpd

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala renamed to compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.dotc
2-
package tastyreflect
2+
package quoted
3+
package reflect
34

45
import dotty.tools.dotc.ast.Trees._
56
import dotty.tools.dotc.ast.{TreeTypeMap, Trees, tpd, untpd}
@@ -8,11 +9,11 @@ import dotty.tools.dotc.core._
89
import dotty.tools.dotc.core.Flags._
910
import dotty.tools.dotc.core.Contexts._
1011
import dotty.tools.dotc.core.StdNames._
11-
import dotty.tools.dotc.core.quoted.PickledQuotes
1212
import dotty.tools.dotc.core.Symbols._
1313
import dotty.tools.dotc.core.Decorators._
1414
import dotty.tools.dotc.core.Types.SingletonType
15-
import dotty.tools.dotc.tastyreflect.FromSymbol.{definitionFromSym, packageDefFromSym}
15+
import dotty.tools.dotc.quoted._
16+
import dotty.tools.dotc.quoted.reflect.FromSymbol.{definitionFromSym, packageDefFromSym}
1617
import dotty.tools.dotc.typer.Implicits.{AmbiguousImplicits, DivergingImplicit, NoMatchingImplicits, SearchFailure, SearchFailureType}
1718
import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans}
1819

@@ -30,7 +31,7 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte
3031
private given core.Contexts.Context = rootContext
3132

3233
def rootPosition: util.SourcePosition =
33-
tastyreflect.MacroExpansion.position.getOrElse(SourcePosition(rootContext.source, Spans.NoSpan))
34+
MacroExpansion.position.getOrElse(SourcePosition(rootContext.source, Spans.NoSpan))
3435

3536

3637
//////////////////////

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala renamed to compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionImpl.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package dotty.tools.dotc.tastyreflect
1+
package dotty.tools.dotc.quoted
2+
package reflect
23

34
import dotty.tools.dotc.ast.tpd
45
import dotty.tools.dotc.core._

compiler/src/dotty/tools/dotc/tastyreflect/package.scala renamed to compiler/src/dotty/tools/dotc/quoted/reflect/package.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
package dotty.tools.dotc
1+
package dotty.tools.dotc.quoted
22

33
import dotty.tools.dotc.ast.Trees.{Tree, Untyped}
44
import dotty.tools.dotc.core.Contexts._
55
import dotty.tools.dotc.core.Symbols.Symbol
66
import dotty.tools.dotc.core.Types.Type
7+
import dotty.tools.dotc.util.SourceFile
78
import dotty.tools.dotc.core.SymDenotations.SymDenotation
89
import scala.annotation.constructorOnly
9-
import util.SourceFile
1010

11-
package object tastyreflect {
11+
package object reflect {
1212

1313
type PackageDefinition = PackageDefinitionImpl[Type]
1414

1515
/** Represents the symbol of a definition in tree form */
16-
case class PackageDefinitionImpl[-T >: Untyped] private[tastyreflect] (sym: Symbol)(implicit @constructorOnly src: SourceFile) extends Tree[T] {
16+
case class PackageDefinitionImpl[-T >: Untyped] private[reflect] (sym: Symbol)(implicit @constructorOnly src: SourceFile) extends Tree[T] {
1717
type ThisTree[-T >: Untyped] = PackageDefinitionImpl[T]
1818

1919
override def denot(using Context): SymDenotation = sym.denot

0 commit comments

Comments
 (0)