Skip to content

Rename CompilerInterface to QuoteContextInternal #10209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/quoted/Matcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions library/src-bootstrapped/scala/internal/quoted/Expr.scala
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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}` */
Expand Down
4 changes: 1 addition & 3 deletions library/src-bootstrapped/scala/internal/quoted/Type.scala
Original file line number Diff line number Diff line change
@@ -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] {
Expand Down Expand Up @@ -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]]
}


Expand Down
6 changes: 2 additions & 4 deletions library/src/scala/internal/quoted/PickledQuote.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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]

}