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

compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import dotty.tools.dotc.core.Constants._
88
import dotty.tools.dotc.core.Contexts._
99
import dotty.tools.dotc.core.Decorators._
1010
import dotty.tools.dotc.core.Flags._
11-
import dotty.tools.dotc.core.quoted._
1211
import dotty.tools.dotc.core.NameKinds._
1312
import dotty.tools.dotc.core.StagingContext._
1413
import dotty.tools.dotc.core.StdNames._
1514
import dotty.tools.dotc.core.Symbols._
1615
import dotty.tools.dotc.core.Types._
16+
import dotty.tools.dotc.quoted._
1717
import dotty.tools.dotc.util.SrcPos
1818
import dotty.tools.dotc.util.Spans._
1919
import dotty.tools.dotc.transform.SymUtils._

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import scala.collection.mutable
2121
import dotty.tools.dotc.core.Annotations._
2222
import dotty.tools.dotc.core.Names._
2323
import dotty.tools.dotc.core.StdNames._
24-
import dotty.tools.dotc.core.quoted._
24+
import dotty.tools.dotc.quoted._
2525
import dotty.tools.dotc.transform.TreeMapWithStages._
2626
import dotty.tools.dotc.typer.Inliner
2727

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ import dotty.tools.dotc.core.Flags._
1212
import dotty.tools.dotc.core.NameKinds.FlatName
1313
import dotty.tools.dotc.core.Names.{Name, TermName}
1414
import dotty.tools.dotc.core.StdNames._
15-
import dotty.tools.dotc.core.quoted._
1615
import dotty.tools.dotc.core.Types._
1716
import dotty.tools.dotc.core.Symbols._
1817
import dotty.tools.dotc.core.Denotations.staticRef
1918
import dotty.tools.dotc.core.{NameKinds, TypeErasure}
2019
import dotty.tools.dotc.core.Constants.Constant
21-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
2220

2321
import scala.util.control.NonFatal
2422
import dotty.tools.dotc.util.SrcPos
2523
import dotty.tools.repl.AbstractFileClassLoader
2624

2725
import scala.reflect.ClassTag
2826

29-
import dotty.tools.dotc.quoted.QuoteContext
27+
import dotty.tools.dotc.quoted._
28+
import scala.quoted.QuoteContext
3029

3130
/** Utility class to splice quoted expressions */
3231
object Splicer {
@@ -50,8 +49,8 @@ object Splicer {
5049
val interpreter = new Interpreter(pos, classLoader)
5150

5251
// Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree
53-
val interpretedExpr = interpreter.interpret[scala.quoted.QuoteContext => scala.quoted.Expr[Any]](tree)
54-
val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuoteContext())))
52+
val interpretedExpr = interpreter.interpret[QuoteContext => scala.quoted.Expr[Any]](tree)
53+
val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuoteContextImpl())))
5554

5655
checkEscapedVariables(interpretedTree, macroOwner)
5756
} finally {
@@ -304,10 +303,10 @@ object Splicer {
304303
}
305304

306305
private def interpretQuote(tree: Tree)(implicit env: Env): Object =
307-
new scala.internal.quoted.Expr(Inlined(EmptyTree, Nil, PickledQuotes.healOwner(tree)).withSpan(tree.span), QuoteContext.scopeId)
306+
new scala.internal.quoted.Expr(Inlined(EmptyTree, Nil, PickledQuotes.healOwner(tree)).withSpan(tree.span), QuoteContextImpl.scopeId)
308307

309308
private def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
310-
new scala.internal.quoted.Type(PickledQuotes.healOwner(tree), QuoteContext.scopeId)
309+
new scala.internal.quoted.Type(PickledQuotes.healOwner(tree), QuoteContextImpl.scopeId)
311310

312311
private def interpretLiteral(value: Any)(implicit env: Env): Object =
313312
value.asInstanceOf[Object]

compiler/src/dotty/tools/dotc/transform/Staging.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import dotty.tools.dotc.core.Contexts._
88
import dotty.tools.dotc.core.Phases._
99
import dotty.tools.dotc.core.Decorators._
1010
import dotty.tools.dotc.core.Flags._
11-
import dotty.tools.dotc.core.quoted._
1211
import dotty.tools.dotc.core.NameKinds._
1312
import dotty.tools.dotc.core.StagingContext._
1413
import dotty.tools.dotc.core.StdNames._
1514
import dotty.tools.dotc.core.Symbols._
1615
import dotty.tools.dotc.core.tasty.TreePickler.Hole
1716
import dotty.tools.dotc.core.Types._
17+
import dotty.tools.dotc.quoted._
1818
import dotty.tools.dotc.util.{SourceFile, SrcPos}
1919
import dotty.tools.dotc.transform.SymUtils._
2020
import dotty.tools.dotc.transform.TreeMapWithStages._

compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import dotty.tools.dotc.config.Printers.staging
77
import dotty.tools.dotc.core.Constants._
88
import dotty.tools.dotc.core.Decorators._
99
import dotty.tools.dotc.core.Flags._
10-
import dotty.tools.dotc.core.quoted._
1110
import dotty.tools.dotc.core.NameKinds._
1211
import dotty.tools.dotc.core.Types._
1312
import dotty.tools.dotc.core.Contexts._
1413
import dotty.tools.dotc.core.StagingContext._
1514
import dotty.tools.dotc.core.StdNames._
1615
import dotty.tools.dotc.core.Symbols._
1716
import dotty.tools.dotc.core.tasty.TreePickler.Hole
17+
import dotty.tools.dotc.quoted._
1818
import dotty.tools.dotc.util.Spans._
1919
import dotty.tools.dotc.util.Property
2020
import dotty.tools.dotc.transform.SymUtils._

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import SymDenotations.SymDenotation
2121
import Inferencing.isFullyDefined
2222
import config.Printers.inlining
2323
import ErrorReporting.errorTree
24-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
2524
import dotty.tools.dotc.util.{SimpleIdentityMap, SimpleIdentitySet, SourceFile, SourcePosition, SrcPos}
2625
import dotty.tools.dotc.parsing.Parsers.Parser
2726
import Nullables.{given _}
@@ -1410,7 +1409,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
14101409
if suspendable then
14111410
ctx.compilationUnit.suspend() // this throws a SuspendException
14121411

1413-
val evaluatedSplice = inContext(tastyreflect.MacroExpansion.context(inlinedFrom)) {
1412+
val evaluatedSplice = inContext(quoted.MacroExpansion.context(inlinedFrom)) {
14141413
Splicer.splice(body, inlinedFrom.srcPos, MacroClassLoader.fromContext)
14151414
}
14161415
val inlinedNormailizer = new TreeMap {

staging/src/scala/quoted/staging/QuoteCompiler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import dotty.tools.dotc.core.Scopes.{EmptyScope, newScope}
1414
import dotty.tools.dotc.core.StdNames.nme
1515
import dotty.tools.dotc.core.Symbols._
1616
import dotty.tools.dotc.core.Types.ExprType
17-
import dotty.tools.dotc.core.quoted.PickledQuotes
18-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
17+
import dotty.tools.dotc.quoted.PickledQuotes
18+
import dotty.tools.dotc.quoted.reflect.ReflectionImpl
1919
import dotty.tools.dotc.transform.Splicer.checkEscapedVariables
2020
import dotty.tools.dotc.transform.ReifyQuotes
2121
import dotty.tools.dotc.util.Spans.Span
@@ -69,7 +69,7 @@ private class QuoteCompiler extends Compiler:
6969

7070
val quoted =
7171
given Context = unitCtx.withOwner(meth)
72-
val qctx = dotty.tools.dotc.quoted.QuoteContext()
72+
val qctx = dotty.tools.dotc.quoted.QuoteContextImpl()
7373
val quoted = PickledQuotes.quotedExprToTree(exprUnit.exprBuilder.apply(qctx))
7474
checkEscapedVariables(quoted, meth)
7575
end quoted

staging/src/scala/quoted/staging/QuoteDriver.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package staging
44
import dotty.tools.dotc.ast.tpd
55
import dotty.tools.dotc.Driver
66
import dotty.tools.dotc.core.Contexts.{Context, ContextBase, FreshContext}
7-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
87
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, VirtualDirectory}
98
import dotty.tools.repl.AbstractFileClassLoader
109
import dotty.tools.dotc.reporting._

tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts.Context
99
import dotty.tools.dotc.core.Mode
1010
import dotty.tools.dotc.core.Phases.Phase
1111
import dotty.tools.dotc.fromtasty._
12-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
12+
import dotty.tools.dotc.quoted.reflect.ReflectionImpl
1313
import dotty.tools.dotc.util.ClasspathFromClassloader
1414

1515
import java.io.File.pathSeparator

0 commit comments

Comments
 (0)