Skip to content

Commit ac88f0e

Browse files
Merge pull request #10209 from dotty-staging/rename-compiler-inteface
Rename CompilerInterface to QuoteContextInternal
2 parents 5c84e42 + 4e1830c commit ac88f0e

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed

compiler/src/dotty/tools/dotc/quoted/Matcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ import scala.quoted._
9797
*/
9898
object Matcher {
9999

100-
abstract class QuoteMatcher[QCtx <: QuoteContext & scala.internal.quoted.CompilerInterface & Singleton](val qctx: QCtx) {
100+
abstract class QuoteMatcher[QCtx <: QuoteContext & Singleton](val qctx: QCtx) {
101101

102102
// TODO improve performance
103103

compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object QuoteContextImpl {
4141

4242
}
4343

44-
class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.internal.quoted.CompilerInterface:
44+
class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.internal.quoted.QuoteContextInternal:
4545

4646
object reflect extends scala.tasty.Reflection:
4747

@@ -2666,7 +2666,6 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
26662666
ctx1
26672667

26682668
val qctx1 = dotty.tools.dotc.quoted.QuoteContextImpl()(using ctx1)
2669-
.asInstanceOf[QuoteContext & scala.internal.quoted.CompilerInterface]
26702669

26712670
val matcher = new Matcher.QuoteMatcher[qctx1.type](qctx1) {
26722671
def patternHoleSymbol: qctx1.reflect.Symbol = dotc.core.Symbols.defn.InternalQuotedPatterns_patternHole.asInstanceOf

library/src-bootstrapped/scala/internal/quoted/Expr.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package scala.internal.quoted
22

33
import scala.quoted._
4-
import scala.internal.quoted.CompilerInterface.quoteContextWithCompilerInterface
54

65
/** An Expr backed by a tree. Only the current compiler trees are allowed.
76
*
@@ -56,8 +55,7 @@ object Expr {
5655
*/
5756
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeExpr: scala.quoted.Expr[Any])
5857
(using patternExpr: scala.quoted.Expr[Any], qctx: QuoteContext): Option[Tup] = {
59-
val qctx1 = quoteContextWithCompilerInterface(qctx)
60-
qctx1.exprMatch(scrutineeExpr, patternExpr).asInstanceOf[Option[Tup]]
58+
qctx.asInstanceOf[QuoteContextInternal].exprMatch(scrutineeExpr, patternExpr).asInstanceOf[Option[Tup]]
6159
}
6260

6361
/** Returns a null expresssion equivalent to `'{null}` */

library/src-bootstrapped/scala/internal/quoted/Type.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package scala.internal.quoted
22

33
import scala.quoted._
4-
import scala.internal.quoted.CompilerInterface.quoteContextWithCompilerInterface
54

65
/** Quoted type (or kind) `T` backed by a tree */
76
final class Type[Tree](val typeTree: Tree, val scopeId: Int) extends scala.quoted.Type[Any] {
@@ -39,8 +38,7 @@ object Type {
3938
*/
4039
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutineeType: scala.quoted.Type[_])
4140
(using patternType: scala.quoted.Type[_], qctx: QuoteContext): Option[Tup] = {
42-
val qctx1 = quoteContextWithCompilerInterface(qctx)
43-
qctx1.typeMatch(scrutineeType, patternType).asInstanceOf[Option[Tup]]
41+
qctx.asInstanceOf[QuoteContextInternal].typeMatch(scrutineeType, patternType).asInstanceOf[Option[Tup]]
4442
}
4543

4644

library/src/scala/internal/quoted/PickledQuote.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ trait PickledQuote:
1717
object PickledQuote:
1818

1919
def unpickleExpr[T](pickledQuote: PickledQuote): QuoteContext ?=> Expr[T] =
20-
val qctx = CompilerInterface.quoteContextWithCompilerInterface(summon[QuoteContext])
21-
qctx.unpickleExpr(pickledQuote).asInstanceOf[Expr[T]]
20+
qctx.asInstanceOf[QuoteContextInternal].unpickleExpr(pickledQuote).asInstanceOf[Expr[T]]
2221

2322
def unpickleType[T](pickledQuote: PickledQuote): QuoteContext ?=> Type[T] =
24-
val qctx = CompilerInterface.quoteContextWithCompilerInterface(summon[QuoteContext])
25-
qctx.unpickleType(pickledQuote).asInstanceOf[Type[T]]
23+
qctx.asInstanceOf[QuoteContextInternal].unpickleType(pickledQuote).asInstanceOf[Type[T]]
2624

2725
/** Create an instance of PickledExpr from encoded tasty and sequence of labmdas to fill holes
2826
*

library/src/scala/internal/quoted/CompilerInterface.scala renamed to library/src/scala/internal/quoted/QuoteContextInternal.scala

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import scala.quoted.QuoteContext
44
import scala.tasty.reflect._
55
import scala.internal.quoted.PickledQuote
66

7-
/** Part of the reflection interface that needs to be implemented by the compiler */
8-
trait CompilerInterface { self: scala.quoted.QuoteContext =>
9-
10-
import self.reflect._
7+
/** Part of the QuoteContext interface that needs to be implemented by the compiler but is not visible to users */
8+
trait QuoteContextInternal { self: scala.quoted.QuoteContext =>
119

1210
/** Unpickle `repr` which represents a pickled `Expr` tree,
1311
* replacing splice nodes with `holes`
@@ -50,11 +48,3 @@ trait CompilerInterface { self: scala.quoted.QuoteContext =>
5048
def typeMatch(scrutinee: scala.quoted.Type[?], pattern: scala.quoted.Type[?]): Option[Tuple]
5149

5250
}
53-
54-
55-
object CompilerInterface {
56-
57-
private[scala] def quoteContextWithCompilerInterface(qctx: QuoteContext): qctx.type { val reflect: qctx.reflect.type } & CompilerInterface =
58-
qctx.asInstanceOf[qctx.type { val reflect: qctx.reflect.type } & CompilerInterface]
59-
60-
}

0 commit comments

Comments
 (0)