diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 5fa0f3d484c9..78fe1bd1b297 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -37,8 +37,7 @@ import scala.annotation.{switch, tailrec} import scala.collection.mutable.ListBuffer import scala.collection.mutable import config.Printers.pickling -import core.quoted.PickledQuotes -import dotty.tools.dotc.quoted.QuoteContext +import quoted.PickledQuotes import dotty.tools.tasty.TastyFormat._ diff --git a/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala b/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala index aa544e46c727..1f067ba0f116 100644 --- a/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala +++ b/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala @@ -8,7 +8,7 @@ import scala.io.Codec import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core.Phases.Phase import dotty.tools.dotc.core.tasty.TastyPrinter -import dotty.tools.dotc.tastyreflect.ReflectionImpl +import dotty.tools.dotc.quoted.QuoteContextImpl import dotty.tools.io.File /** Phase that prints the trees in all loaded compilation units. @@ -43,7 +43,7 @@ class DecompilationPrinter extends Phase { else { val unitFile = unit.source.toString.replace("\\", "/").replace(".class", ".tasty") out.println(s"/** Decompiled from $unitFile */") - out.println(ReflectionImpl.showTree(unit.tpdTree)) + out.println(QuoteContextImpl.showTree(unit.tpdTree)) } } } diff --git a/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala b/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala index e609a7ccbd8b..bd8a668ff4d4 100644 --- a/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala +++ b/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala @@ -6,7 +6,7 @@ import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core._ import dotty.tools.dotc.core.tasty.TastyHTMLPrinter import dotty.tools.dotc.reporting._ -import dotty.tools.dotc.tastyreflect.ReflectionImpl +import dotty.tools.dotc.quoted.QuoteContextImpl /** * Decompiler to be used with IDEs @@ -34,7 +34,7 @@ class IDEDecompilerDriver(val settings: List[String]) extends dotc.Driver { run.printSummary() val unit = ctx.run.units.head - val decompiled = ReflectionImpl.showTree(unit.tpdTree) + val decompiled = QuoteContextImpl.showTree(unit.tpdTree) val tree = new TastyHTMLPrinter(unit.pickled.head._2()).printContents() reporter.removeBufferedMessages.foreach(message => System.err.println(message)) diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/MacroExpansion.scala b/compiler/src/dotty/tools/dotc/quoted/MacroExpansion.scala similarity index 94% rename from compiler/src/dotty/tools/dotc/tastyreflect/MacroExpansion.scala rename to compiler/src/dotty/tools/dotc/quoted/MacroExpansion.scala index 7bc925a03146..90a208814f2a 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/MacroExpansion.scala +++ b/compiler/src/dotty/tools/dotc/quoted/MacroExpansion.scala @@ -1,4 +1,4 @@ -package dotty.tools.dotc.tastyreflect +package dotty.tools.dotc.quoted import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.core._ diff --git a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala b/compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala similarity index 94% rename from compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala rename to compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala index 46eacb5e4c97..bfe1a98f06ab 100644 --- a/compiler/src/dotty/tools/dotc/core/quoted/PickledQuotes.scala +++ b/compiler/src/dotty/tools/dotc/quoted/PickledQuotes.scala @@ -1,4 +1,4 @@ -package dotty.tools.dotc.core.quoted +package dotty.tools.dotc.quoted import dotty.tools.dotc.ast.Trees._ import dotty.tools.dotc.ast.{TreeTypeMap, tpd} @@ -15,14 +15,13 @@ import dotty.tools.dotc.core.tasty.TreePickler.Hole import dotty.tools.dotc.core.tasty.{ PositionPickler, TastyPickler, TastyPrinter } import dotty.tools.dotc.core.tasty.DottyUnpickler import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode -import dotty.tools.dotc.quoted.QuoteContext -import dotty.tools.dotc.tastyreflect.ReflectionImpl import dotty.tools.tasty.TastyString import scala.reflect.ClassTag import scala.internal.quoted.Unpickler._ +import scala.quoted.QuoteContext object PickledQuotes { import tpd._ @@ -39,14 +38,14 @@ object PickledQuotes { /** Transform the expression into its fully spliced Tree */ def quotedExprToTree[T](expr: quoted.Expr[T])(using Context): Tree = { val expr1 = expr.asInstanceOf[scala.internal.quoted.Expr[Tree]] - QuoteContext.checkScopeId(expr1.scopeId) + QuoteContextImpl.checkScopeId(expr1.scopeId) healOwner(expr1.tree) } /** Transform the expression into its fully spliced TypeTree */ def quotedTypeToTree(tpe: quoted.Type[?])(using Context): Tree = { val tpe1 = tpe.asInstanceOf[scala.internal.quoted.Type[Tree]] - QuoteContext.checkScopeId(tpe1.scopeId) + QuoteContextImpl.checkScopeId(tpe1.scopeId) healOwner(tpe1.typeTree) } @@ -76,12 +75,12 @@ object PickledQuotes { override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match { case Hole(isTerm, idx, args) => val reifiedArgs = args.map { arg => - if (arg.isTerm) (using qctx: scala.quoted.QuoteContext) => new scala.internal.quoted.Expr(arg, QuoteContext.scopeId) - else new scala.internal.quoted.Type(arg, QuoteContext.scopeId) + if (arg.isTerm) (using qctx: QuoteContext) => new scala.internal.quoted.Expr(arg, QuoteContextImpl.scopeId) + else new scala.internal.quoted.Type(arg, QuoteContextImpl.scopeId) } if isTerm then - val splice1 = splices(idx).asInstanceOf[Seq[Any] => scala.quoted.QuoteContext ?=> quoted.Expr[?]] - val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContext()) + val splice1 = splices(idx).asInstanceOf[Seq[Any] => QuoteContext ?=> quoted.Expr[?]] + val quotedExpr = splice1(reifiedArgs)(using dotty.tools.dotc.quoted.QuoteContextImpl()) val filled = PickledQuotes.quotedExprToTree(quotedExpr) // We need to make sure a hole is created with the source file of the surrounding context, even if diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala deleted file mode 100644 index 5a3904d89491..000000000000 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala +++ /dev/null @@ -1,23 +0,0 @@ -package dotty.tools.dotc.quoted - -import dotty.tools.dotc.core.Contexts._ -import dotty.tools.dotc.tastyreflect.ReflectionImpl - -object QuoteContext { - - def apply()(using Context): scala.quoted.QuoteContext = - new QuoteContext(ReflectionImpl(summon[Context])) - - type ScopeId = Int - - private[dotty] def checkScopeId(id: ScopeId)(using Context): Unit = - if (id != scopeId) - throw new scala.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`") - - // TODO Explore more fine grained scope ids. - // This id can only differentiate scope extrusion from one compiler instance to another. - private[dotty] def scopeId(using Context): ScopeId = - summon[Context].outersIterator.toList.last.hashCode() -} - -class QuoteContext(val tasty: scala.tasty.Reflection) extends scala.quoted.QuoteContext diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala new file mode 100644 index 000000000000..f9133d65739c --- /dev/null +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala @@ -0,0 +1,43 @@ +package dotty.tools.dotc.quoted + +import dotty.tools.dotc.ast.tpd +import dotty.tools.dotc.core.Contexts._ +import dotty.tools.dotc.quoted.reflect._ + +import scala.quoted.QuoteContext +import scala.quoted.show.SyntaxHighlight + +object QuoteContextImpl { + + type ScopeId = Int + + def apply()(using Context): QuoteContext = + new QuoteContextImpl(ctx) + + def showTree(tree: tpd.Tree)(using Context): String = { + val qctx = QuoteContextImpl()(using MacroExpansion.context(tree)) + val syntaxHighlight = + if (ctx.settings.color.value == "always") SyntaxHighlight.ANSI + else SyntaxHighlight.plain + show(using qctx)(tree.asInstanceOf[qctx.tasty.Tree], syntaxHighlight)(using ctx.asInstanceOf[qctx.tasty.Context]) + } + + private def show(using qctx: QuoteContext)(tree: qctx.tasty.Tree, syntaxHighlight: SyntaxHighlight)(using qctx.tasty.Context) = + tree.showWith(syntaxHighlight) + + private[dotty] def checkScopeId(id: ScopeId)(using Context): Unit = + if (id != scopeId) + throw new scala.quoted.ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`") + + // TODO Explore more fine grained scope ids. + // This id can only differentiate scope extrusion from one compiler instance to another. + private[dotty] def scopeId(using Context): ScopeId = + ctx.outersIterator.toList.last.hashCode() + +} + +class QuoteContextImpl private (ctx: Context) extends QuoteContext { + // NOTE: The tasty class should only mixin the compiler interface and the reflection interface. + // We should not implement methods here, all should be implemented by `ReflectionCompilerInterface` + val tasty = new ReflectionCompilerInterface(ctx) with scala.tasty.Reflection +} diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala b/compiler/src/dotty/tools/dotc/quoted/reflect/FromSymbol.scala similarity index 98% rename from compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala rename to compiler/src/dotty/tools/dotc/quoted/reflect/FromSymbol.scala index 14ba0dca6d56..7f90ecabfd09 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/FromSymbol.scala +++ b/compiler/src/dotty/tools/dotc/quoted/reflect/FromSymbol.scala @@ -1,4 +1,5 @@ -package dotty.tools.dotc.tastyreflect +package dotty.tools.dotc.quoted +package reflect import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.ast.untpd diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala b/compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala similarity index 99% rename from compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala rename to compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala index f15e35ab1a0e..dd3d6fefe48f 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala +++ b/compiler/src/dotty/tools/dotc/quoted/reflect/ReflectionCompilerInterface.scala @@ -1,5 +1,6 @@ package dotty.tools.dotc -package tastyreflect +package quoted +package reflect import dotty.tools.dotc.ast.Trees._ import dotty.tools.dotc.ast.{TreeTypeMap, Trees, tpd, untpd} @@ -8,11 +9,11 @@ import dotty.tools.dotc.core._ import dotty.tools.dotc.core.Flags._ import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core.StdNames._ -import dotty.tools.dotc.core.quoted.PickledQuotes import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.Decorators._ import dotty.tools.dotc.core.Types.SingletonType -import dotty.tools.dotc.tastyreflect.FromSymbol.{definitionFromSym, packageDefFromSym} +import dotty.tools.dotc.quoted._ +import dotty.tools.dotc.quoted.reflect.FromSymbol.{definitionFromSym, packageDefFromSym} import dotty.tools.dotc.typer.Implicits.{AmbiguousImplicits, DivergingImplicit, NoMatchingImplicits, SearchFailure, SearchFailureType} import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans} @@ -30,7 +31,7 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte private given core.Contexts.Context = rootContext def rootPosition: util.SourcePosition = - tastyreflect.MacroExpansion.position.getOrElse(SourcePosition(rootContext.source, Spans.NoSpan)) + MacroExpansion.position.getOrElse(SourcePosition(rootContext.source, Spans.NoSpan)) ////////////////////// diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/package.scala b/compiler/src/dotty/tools/dotc/quoted/reflect/package.scala similarity index 68% rename from compiler/src/dotty/tools/dotc/tastyreflect/package.scala rename to compiler/src/dotty/tools/dotc/quoted/reflect/package.scala index 3f2f98ed200a..4f8475bfce6a 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/package.scala +++ b/compiler/src/dotty/tools/dotc/quoted/reflect/package.scala @@ -1,19 +1,19 @@ -package dotty.tools.dotc +package dotty.tools.dotc.quoted import dotty.tools.dotc.ast.Trees.{Tree, Untyped} import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core.Symbols.Symbol import dotty.tools.dotc.core.Types.Type +import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.core.SymDenotations.SymDenotation import scala.annotation.constructorOnly -import util.SourceFile -package object tastyreflect { +package object reflect { type PackageDefinition = PackageDefinitionImpl[Type] /** Represents the symbol of a definition in tree form */ - case class PackageDefinitionImpl[-T >: Untyped] private[tastyreflect] (sym: Symbol)(implicit @constructorOnly src: SourceFile) extends Tree[T] { + case class PackageDefinitionImpl[-T >: Untyped] private[reflect] (sym: Symbol)(implicit @constructorOnly src: SourceFile) extends Tree[T] { type ThisTree[-T >: Untyped] = PackageDefinitionImpl[T] override def denot(using Context): SymDenotation = sym.denot diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala deleted file mode 100644 index 7d715b5e65bf..000000000000 --- a/compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala +++ /dev/null @@ -1,27 +0,0 @@ -package dotty.tools.dotc.tastyreflect - -import dotty.tools.dotc.ast.tpd -import dotty.tools.dotc.core._ -import dotty.tools.dotc.core.Contexts._ - -import scala.quoted.show.SyntaxHighlight - -object ReflectionImpl { - - def apply(rootContext: Contexts.Context): scala.tasty.Reflection = - new ReflectionImpl(rootContext) - - def showTree(tree: tpd.Tree)(using Contexts.Context): String = { - val refl = new ReflectionImpl(MacroExpansion.context(tree)) - val reflCtx = ctx.asInstanceOf[refl.Context] - val reflTree = tree.asInstanceOf[refl.Tree] - val syntaxHighlight = - if (ctx.settings.color.value == "always") SyntaxHighlight.ANSI - else SyntaxHighlight.plain - new scala.tasty.reflect.SourceCodePrinter[refl.type](refl)(syntaxHighlight).showTree(reflTree)(using reflCtx) - } -} - -// NOTE: This class should only mixin the compiler interface and the reflection interface. -// We should not implement methods here, all should be implemented by `ReflectionCompilerInterface` -class ReflectionImpl(ctx: Context) extends ReflectionCompilerInterface(ctx) with scala.tasty.Reflection diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 9afe86734f6d..d48025220850 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -8,12 +8,12 @@ import dotty.tools.dotc.core.Constants._ import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core.Decorators._ import dotty.tools.dotc.core.Flags._ -import dotty.tools.dotc.core.quoted._ import dotty.tools.dotc.core.NameKinds._ import dotty.tools.dotc.core.StagingContext._ import dotty.tools.dotc.core.StdNames._ import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.Types._ +import dotty.tools.dotc.quoted._ import dotty.tools.dotc.util.SrcPos import dotty.tools.dotc.util.Spans._ import dotty.tools.dotc.transform.SymUtils._ diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index ec0e0a7ff15d..783309be7ebd 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -21,7 +21,7 @@ import scala.collection.mutable import dotty.tools.dotc.core.Annotations._ import dotty.tools.dotc.core.Names._ import dotty.tools.dotc.core.StdNames._ -import dotty.tools.dotc.core.quoted._ +import dotty.tools.dotc.quoted._ import dotty.tools.dotc.transform.TreeMapWithStages._ import dotty.tools.dotc.typer.Inliner diff --git a/compiler/src/dotty/tools/dotc/transform/Splicer.scala b/compiler/src/dotty/tools/dotc/transform/Splicer.scala index ed3a35ebaee7..bb78689a3746 100644 --- a/compiler/src/dotty/tools/dotc/transform/Splicer.scala +++ b/compiler/src/dotty/tools/dotc/transform/Splicer.scala @@ -12,13 +12,11 @@ import dotty.tools.dotc.core.Flags._ import dotty.tools.dotc.core.NameKinds.FlatName import dotty.tools.dotc.core.Names.{Name, TermName} import dotty.tools.dotc.core.StdNames._ -import dotty.tools.dotc.core.quoted._ import dotty.tools.dotc.core.Types._ import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.Denotations.staticRef import dotty.tools.dotc.core.{NameKinds, TypeErasure} import dotty.tools.dotc.core.Constants.Constant -import dotty.tools.dotc.tastyreflect.ReflectionImpl import scala.util.control.NonFatal import dotty.tools.dotc.util.SrcPos @@ -26,7 +24,8 @@ import dotty.tools.repl.AbstractFileClassLoader import scala.reflect.ClassTag -import dotty.tools.dotc.quoted.QuoteContext +import dotty.tools.dotc.quoted._ +import scala.quoted.QuoteContext /** Utility class to splice quoted expressions */ object Splicer { @@ -50,8 +49,8 @@ object Splicer { val interpreter = new Interpreter(pos, classLoader) // Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree - val interpretedExpr = interpreter.interpret[scala.quoted.QuoteContext => scala.quoted.Expr[Any]](tree) - val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuoteContext()))) + val interpretedExpr = interpreter.interpret[QuoteContext => scala.quoted.Expr[Any]](tree) + val interpretedTree = interpretedExpr.fold(tree)(macroClosure => PickledQuotes.quotedExprToTree(macroClosure(QuoteContextImpl()))) checkEscapedVariables(interpretedTree, macroOwner) } finally { @@ -304,10 +303,10 @@ object Splicer { } private def interpretQuote(tree: Tree)(implicit env: Env): Object = - new scala.internal.quoted.Expr(Inlined(EmptyTree, Nil, PickledQuotes.healOwner(tree)).withSpan(tree.span), QuoteContext.scopeId) + new scala.internal.quoted.Expr(Inlined(EmptyTree, Nil, PickledQuotes.healOwner(tree)).withSpan(tree.span), QuoteContextImpl.scopeId) private def interpretTypeQuote(tree: Tree)(implicit env: Env): Object = - new scala.internal.quoted.Type(PickledQuotes.healOwner(tree), QuoteContext.scopeId) + new scala.internal.quoted.Type(PickledQuotes.healOwner(tree), QuoteContextImpl.scopeId) private def interpretLiteral(value: Any)(implicit env: Env): Object = value.asInstanceOf[Object] diff --git a/compiler/src/dotty/tools/dotc/transform/Staging.scala b/compiler/src/dotty/tools/dotc/transform/Staging.scala index efaa6b8059bf..7878cf1d9dd8 100644 --- a/compiler/src/dotty/tools/dotc/transform/Staging.scala +++ b/compiler/src/dotty/tools/dotc/transform/Staging.scala @@ -8,13 +8,13 @@ import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core.Phases._ import dotty.tools.dotc.core.Decorators._ import dotty.tools.dotc.core.Flags._ -import dotty.tools.dotc.core.quoted._ import dotty.tools.dotc.core.NameKinds._ import dotty.tools.dotc.core.StagingContext._ import dotty.tools.dotc.core.StdNames._ import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.tasty.TreePickler.Hole import dotty.tools.dotc.core.Types._ +import dotty.tools.dotc.quoted._ import dotty.tools.dotc.util.{SourceFile, SrcPos} import dotty.tools.dotc.transform.SymUtils._ import dotty.tools.dotc.transform.TreeMapWithStages._ diff --git a/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala b/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala index 5d7f76441d08..a1ae110990f7 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeMapWithStages.scala @@ -7,7 +7,6 @@ import dotty.tools.dotc.config.Printers.staging import dotty.tools.dotc.core.Constants._ import dotty.tools.dotc.core.Decorators._ import dotty.tools.dotc.core.Flags._ -import dotty.tools.dotc.core.quoted._ import dotty.tools.dotc.core.NameKinds._ import dotty.tools.dotc.core.Types._ import dotty.tools.dotc.core.Contexts._ @@ -15,6 +14,7 @@ import dotty.tools.dotc.core.StagingContext._ import dotty.tools.dotc.core.StdNames._ import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.tasty.TreePickler.Hole +import dotty.tools.dotc.quoted._ import dotty.tools.dotc.util.Spans._ import dotty.tools.dotc.util.Property import dotty.tools.dotc.transform.SymUtils._ diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 9af8f9ac06c9..89d37f77f037 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -21,7 +21,6 @@ import SymDenotations.SymDenotation import Inferencing.isFullyDefined import config.Printers.inlining import ErrorReporting.errorTree -import dotty.tools.dotc.tastyreflect.ReflectionImpl import dotty.tools.dotc.util.{SimpleIdentityMap, SimpleIdentitySet, SourceFile, SourcePosition, SrcPos} import dotty.tools.dotc.parsing.Parsers.Parser import Nullables.{given _} @@ -1410,7 +1409,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { if suspendable then ctx.compilationUnit.suspend() // this throws a SuspendException - val evaluatedSplice = inContext(tastyreflect.MacroExpansion.context(inlinedFrom)) { + val evaluatedSplice = inContext(quoted.MacroExpansion.context(inlinedFrom)) { Splicer.splice(body, inlinedFrom.srcPos, MacroClassLoader.fromContext) } val inlinedNormailizer = new TreeMap { diff --git a/staging/src/scala/quoted/staging/QuoteCompiler.scala b/staging/src/scala/quoted/staging/QuoteCompiler.scala index 4cda6a7f5cc8..5f8c31c8c6ba 100644 --- a/staging/src/scala/quoted/staging/QuoteCompiler.scala +++ b/staging/src/scala/quoted/staging/QuoteCompiler.scala @@ -14,8 +14,7 @@ import dotty.tools.dotc.core.Scopes.{EmptyScope, newScope} import dotty.tools.dotc.core.StdNames.nme import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.Types.ExprType -import dotty.tools.dotc.core.quoted.PickledQuotes -import dotty.tools.dotc.tastyreflect.ReflectionImpl +import dotty.tools.dotc.quoted.PickledQuotes import dotty.tools.dotc.transform.Splicer.checkEscapedVariables import dotty.tools.dotc.transform.ReifyQuotes import dotty.tools.dotc.util.Spans.Span @@ -69,7 +68,7 @@ private class QuoteCompiler extends Compiler: val quoted = given Context = unitCtx.withOwner(meth) - val qctx = dotty.tools.dotc.quoted.QuoteContext() + val qctx = dotty.tools.dotc.quoted.QuoteContextImpl() val quoted = PickledQuotes.quotedExprToTree(exprUnit.exprBuilder.apply(qctx)) checkEscapedVariables(quoted, meth) end quoted diff --git a/staging/src/scala/quoted/staging/QuoteDriver.scala b/staging/src/scala/quoted/staging/QuoteDriver.scala index 9f33570f4187..2f1fd628f839 100644 --- a/staging/src/scala/quoted/staging/QuoteDriver.scala +++ b/staging/src/scala/quoted/staging/QuoteDriver.scala @@ -4,7 +4,6 @@ package staging import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.Driver import dotty.tools.dotc.core.Contexts.{Context, ContextBase, FreshContext} -import dotty.tools.dotc.tastyreflect.ReflectionImpl import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, VirtualDirectory} import dotty.tools.repl.AbstractFileClassLoader import dotty.tools.dotc.reporting._ diff --git a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala index 0811ee9c0c09..7fc68cc7f546 100644 --- a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala +++ b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala @@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Mode import dotty.tools.dotc.core.Phases.Phase import dotty.tools.dotc.fromtasty._ -import dotty.tools.dotc.tastyreflect.ReflectionImpl +import dotty.tools.dotc.quoted.QuoteContextImpl import dotty.tools.dotc.util.ClasspathFromClassloader import java.io.File.pathSeparator @@ -57,8 +57,8 @@ trait TastyInspector: override def phaseName: String = "tastyInspector" override def run(implicit ctx: Context): Unit = - val reflect = ReflectionImpl(ctx) - self.processCompilationUnit(reflect)(ctx.compilationUnit.tpdTree.asInstanceOf[reflect.Tree]) + val qctx = QuoteContextImpl() + self.processCompilationUnit(qctx.tasty)(ctx.compilationUnit.tpdTree.asInstanceOf[qctx.tasty.Tree]) end TastyInspectorPhase