diff --git a/compiler/src/dotty/tools/dotc/quoted/Matcher.scala b/compiler/src/dotty/tools/dotc/quoted/Matcher.scala index dda40070d7d8..d8fcb61398d9 100644 --- a/compiler/src/dotty/tools/dotc/quoted/Matcher.scala +++ b/compiler/src/dotty/tools/dotc/quoted/Matcher.scala @@ -97,7 +97,7 @@ import scala.quoted._ */ object Matcher { - abstract class QuoteMatcher[QCtx <: QuoteContext & scala.internal.quoted.CompilerInterface & Singleton](val qctx: QCtx) { + abstract class QuoteMatcher[QCtx <: QuoteContext & Singleton](val qctx: QCtx) { // TODO improve performance diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala index 6d820094c216..2749e24f9895 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala @@ -45,7 +45,7 @@ object QuoteContextImpl { } -class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.internal.quoted.CompilerInterface: +class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.internal.quoted.QuoteContextInternal: object reflect extends scala.tasty.Reflection: @@ -2670,7 +2670,6 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern ctx1 val qctx1 = dotty.tools.dotc.quoted.QuoteContextImpl()(using ctx1) - .asInstanceOf[QuoteContext & scala.internal.quoted.CompilerInterface] val matcher = new Matcher.QuoteMatcher[qctx1.type](qctx1) { def patternHoleSymbol: qctx1.reflect.Symbol = dotc.core.Symbols.defn.InternalQuotedPatterns_patternHole.asInstanceOf diff --git a/library/src-bootstrapped/scala/internal/quoted/Expr.scala b/library/src-bootstrapped/scala/internal/quoted/Expr.scala index 3bb78a5ae035..8175d4b115ed 100644 --- a/library/src-bootstrapped/scala/internal/quoted/Expr.scala +++ b/library/src-bootstrapped/scala/internal/quoted/Expr.scala @@ -1,7 +1,6 @@ package scala.internal.quoted import scala.quoted._ -import scala.internal.quoted.CompilerInterface.quoteContextWithCompilerInterface /** An Expr backed by a tree. Only the current compiler trees are allowed. * @@ -53,8 +52,7 @@ object Expr { */ def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[Any]) (using patternExpr: scala.quoted.Expr[Any], qctx: QuoteContext): Option[Tup] = { - val qctx1 = quoteContextWithCompilerInterface(qctx) - qctx1.exprMatch(scrutineeExpr, patternExpr).asInstanceOf[Option[Tup]] + qctx.asInstanceOf[QuoteContextInternal].exprMatch(scrutineeExpr, patternExpr).asInstanceOf[Option[Tup]] } /** Returns a null expresssion equivalent to `'{null}` */ diff --git a/library/src-bootstrapped/scala/internal/quoted/Type.scala b/library/src-bootstrapped/scala/internal/quoted/Type.scala index cbe730578d51..f360a2dcea1d 100644 --- a/library/src-bootstrapped/scala/internal/quoted/Type.scala +++ b/library/src-bootstrapped/scala/internal/quoted/Type.scala @@ -1,7 +1,6 @@ package scala.internal.quoted import scala.quoted._ -import scala.internal.quoted.CompilerInterface.quoteContextWithCompilerInterface /** Quoted type (or kind) `T` backed by a tree */ final class Type[Tree](val typeTree: Tree, val scopeId: Int) extends scala.quoted.Type[Any] { @@ -36,8 +35,7 @@ object Type { */ def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: scala.quoted.Type[_]) (using patternType: scala.quoted.Type[_], qctx: QuoteContext): Option[Tup] = { - val qctx1 = quoteContextWithCompilerInterface(qctx) - qctx1.typeMatch(scrutineeType, patternType).asInstanceOf[Option[Tup]] + qctx.asInstanceOf[QuoteContextInternal].typeMatch(scrutineeType, patternType).asInstanceOf[Option[Tup]] } diff --git a/library/src/scala/internal/quoted/PickledQuote.scala b/library/src/scala/internal/quoted/PickledQuote.scala index db8b1e2ce7f7..6c44109c41e7 100644 --- a/library/src/scala/internal/quoted/PickledQuote.scala +++ b/library/src/scala/internal/quoted/PickledQuote.scala @@ -17,12 +17,10 @@ trait PickledQuote: object PickledQuote: def unpickleExpr[T](pickledQuote: PickledQuote): QuoteContext ?=> Expr[T] = - val qctx = CompilerInterface.quoteContextWithCompilerInterface(summon[QuoteContext]) - qctx.unpickleExpr(pickledQuote).asInstanceOf[Expr[T]] + qctx.asInstanceOf[QuoteContextInternal].unpickleExpr(pickledQuote).asInstanceOf[Expr[T]] def unpickleType[T](pickledQuote: PickledQuote): QuoteContext ?=> Type[T] = - val qctx = CompilerInterface.quoteContextWithCompilerInterface(summon[QuoteContext]) - qctx.unpickleType(pickledQuote).asInstanceOf[Type[T]] + qctx.asInstanceOf[QuoteContextInternal].unpickleType(pickledQuote).asInstanceOf[Type[T]] /** Create an instance of PickledExpr from encoded tasty and sequence of labmdas to fill holes * diff --git a/library/src/scala/internal/quoted/CompilerInterface.scala b/library/src/scala/internal/quoted/QuoteContextInternal.scala similarity index 82% rename from library/src/scala/internal/quoted/CompilerInterface.scala rename to library/src/scala/internal/quoted/QuoteContextInternal.scala index 0d0c8174501d..0efdbb9f5945 100644 --- a/library/src/scala/internal/quoted/CompilerInterface.scala +++ b/library/src/scala/internal/quoted/QuoteContextInternal.scala @@ -4,10 +4,8 @@ import scala.quoted.QuoteContext import scala.tasty.reflect._ import scala.internal.quoted.PickledQuote -/** Part of the reflection interface that needs to be implemented by the compiler */ -trait CompilerInterface { self: scala.quoted.QuoteContext => - - import self.reflect._ +/** Part of the QuoteContext interface that needs to be implemented by the compiler but is not visible to users */ +trait QuoteContextInternal { self: scala.quoted.QuoteContext => /** Unpickle `repr` which represents a pickled `Expr` tree, * replacing splice nodes with `holes` @@ -50,11 +48,3 @@ trait CompilerInterface { self: scala.quoted.QuoteContext => def typeMatch(scrutinee: scala.quoted.Type[?], pattern: scala.quoted.Type[?]): Option[Tuple] } - - -object CompilerInterface { - - private[scala] def quoteContextWithCompilerInterface(qctx: QuoteContext): qctx.type { val reflect: qctx.reflect.type } & CompilerInterface = - qctx.asInstanceOf[qctx.type { val reflect: qctx.reflect.type } & CompilerInterface] - -}