Skip to content

Commit 74e98d4

Browse files
committed
Move scala.quoted.internal into the library
1 parent 388b820 commit 74e98d4

File tree

9 files changed

+30
-22
lines changed

9 files changed

+30
-22
lines changed

compiler/src/scala/quoted/internal/Expr.scala renamed to compiler/src/dotty/tools/dotc/quoted/ExprImpl.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.quoted.internal
1+
package dotty.tools.dotc.quoted
22

33
import scala.quoted._
44

@@ -11,9 +11,9 @@ import dotty.tools.dotc.ast.tpd
1111
*
1212
* May contain references to code defined outside this Expr instance.
1313
*/
14-
final class Expr(val tree: tpd.Tree, val scopeId: Int) extends scala.quoted.Expr[Any] {
14+
final class ExprImpl(val tree: tpd.Tree, val scopeId: Int) extends scala.quoted.internal.Expr[Any] {
1515
override def equals(that: Any): Boolean = that match {
16-
case that: Expr =>
16+
case that: ExprImpl =>
1717
// Expr are wrappers around trees, therefore they are equals if their trees are equal.
1818
// All scopeId should be equal unless two different runs of the compiler created the trees.
1919
tree == that.tree && scopeId == that.scopeId

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ object PickledQuotes {
3838

3939
/** Transform the expression into its fully spliced Tree */
4040
def quotedExprToTree[T](expr: quoted.Expr[T])(using Context): Tree = {
41-
val expr1 = expr.asInstanceOf[scala.quoted.internal.Expr]
41+
val expr1 = expr.asInstanceOf[dotty.tools.dotc.quoted.ExprImpl]
4242
expr1.checkScopeId(QuoteContextImpl.scopeId)
4343
changeOwnerOfTree(expr1.tree, ctx.owner)
4444
}
4545

4646
/** Transform the expression into its fully spliced TypeTree */
4747
def quotedTypeToTree(tpe: quoted.Type[?])(using Context): Tree = {
48-
val tpe1 = tpe.asInstanceOf[scala.quoted.internal.Type]
48+
val tpe1 = tpe.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl]
4949
tpe1.checkScopeId(QuoteContextImpl.scopeId)
5050
changeOwnerOfTree(tpe1.typeTree, ctx.owner)
5151
}
@@ -72,8 +72,8 @@ object PickledQuotes {
7272
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {
7373
case Hole(isTerm, idx, args) =>
7474
val reifiedArgs = args.map { arg =>
75-
if (arg.isTerm) (using qctx: QuoteContext) => new scala.quoted.internal.Expr(arg, QuoteContextImpl.scopeId)
76-
else new scala.quoted.internal.Type(arg, QuoteContextImpl.scopeId)
75+
if (arg.isTerm) (using qctx: QuoteContext) => new dotty.tools.dotc.quoted.ExprImpl(arg, QuoteContextImpl.scopeId)
76+
else new dotty.tools.dotc.quoted.TypeImpl(arg, QuoteContextImpl.scopeId)
7777
}
7878
if isTerm then
7979
val quotedExpr = termHole(idx, reifiedArgs, dotty.tools.dotc.quoted.QuoteContextImpl())

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
7171
case _ => false
7272
def asExpr: scala.quoted.Expr[Any] =
7373
if self.isExpr then
74-
new scala.quoted.internal.Expr(self, QuoteContextImpl.this.hashCode)
74+
new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode)
7575
else self match
7676
case TermTypeTest(self) => throw new Exception("Expected an expression. This is a partially applied Term. Try eta-expanding the term first.")
7777
case _ => throw new Exception("Expected a Term but was: " + self)
@@ -315,11 +315,11 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
315315
object TermMethodsImpl extends TermMethods:
316316
extension (self: Term):
317317
def seal: scala.quoted.Expr[Any] =
318-
if self.isExpr then new scala.quoted.internal.Expr(self, QuoteContextImpl.this.hashCode)
318+
if self.isExpr then new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode)
319319
else throw new Exception("Cannot seal a partially applied Term. Try eta-expanding the term first.")
320320

321321
def sealOpt: Option[scala.quoted.Expr[Any]] =
322-
if self.isExpr then Some(new scala.quoted.internal.Expr(self, QuoteContextImpl.this.hashCode))
322+
if self.isExpr then Some(new dotty.tools.dotc.quoted.ExprImpl(self, QuoteContextImpl.this.hashCode))
323323
else None
324324

325325
def tpe: TypeRepr = self.tpe
@@ -1002,7 +1002,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
10021002

10031003
object TypeTree extends TypeTreeModule:
10041004
def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeTree =
1005-
tp.asInstanceOf[scala.quoted.internal.Type].typeTree
1005+
tp.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl].typeTree
10061006
end TypeTree
10071007

10081008
object TypeTreeMethodsImpl extends TypeTreeMethods:
@@ -1571,7 +1571,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
15711571

15721572
object TypeRepr extends TypeReprModule:
15731573
def of[T <: AnyKind](using tp: scala.quoted.Type[T]): TypeRepr =
1574-
tp.asInstanceOf[scala.quoted.internal.Type].typeTree.tpe
1574+
tp.asInstanceOf[dotty.tools.dotc.quoted.TypeImpl].typeTree.tpe
15751575
def typeConstructorOf(clazz: Class[?]): TypeRepr =
15761576
if (clazz.isPrimitive)
15771577
if (clazz == classOf[Boolean]) dotc.core.Symbols.defn.BooleanType
@@ -1608,7 +1608,7 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
16081608
def seal: scala.quoted.Type[_] = self.asType
16091609

16101610
def asType: scala.quoted.Type[?] =
1611-
new scala.quoted.internal.Type(Inferred(self), QuoteContextImpl.this.hashCode)
1611+
new dotty.tools.dotc.quoted.TypeImpl(Inferred(self), QuoteContextImpl.this.hashCode)
16121612

16131613
def =:=(that: TypeRepr): Boolean = self =:= that
16141614
def <:<(that: TypeRepr): Boolean = self <:< that
@@ -2623,11 +2623,11 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, scala.intern
26232623

26242624
def unpickleExpr[T](pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?]): scala.quoted.Expr[T] =
26252625
val tree = PickledQuotes.unpickleTerm(pickled, typeHole, termHole)(using reflect.rootContext)
2626-
new scala.quoted.internal.Expr(tree, hash).asInstanceOf[scala.quoted.Expr[T]]
2626+
new dotty.tools.dotc.quoted.ExprImpl(tree, hash).asInstanceOf[scala.quoted.Expr[T]]
26272627

26282628
def unpickleType[T <: AnyKind](pickled: String | List[String], typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Any], scala.quoted.QuoteContext) => scala.quoted.Expr[?]): scala.quoted.Type[T] =
26292629
val tree = PickledQuotes.unpickleTypeTree(pickled, typeHole, termHole)(using reflect.rootContext)
2630-
new scala.quoted.internal.Type(tree, hash).asInstanceOf[scala.quoted.Type[T]]
2630+
new dotty.tools.dotc.quoted.TypeImpl(tree, hash).asInstanceOf[scala.quoted.Type[T]]
26312631

26322632
object ExprMatch extends ExprMatchModule:
26332633
def unapply[TypeBindings <: Tuple, Tup <: Tuple](scrutinee: scala.quoted.Expr[Any])(using pattern: scala.quoted.Expr[Any]): Option[Tup] =
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
package scala.quoted.internal
1+
package dotty.tools.dotc.quoted
22

33
class ScopeException(msg: String) extends Exception(msg)

compiler/src/scala/quoted/internal/Type.scala renamed to compiler/src/dotty/tools/dotc/quoted/TypeImpl.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package scala.quoted.internal
1+
package dotty.tools.dotc.quoted
22

33
import scala.quoted._
44

55
import dotty.tools.dotc.ast.tpd
66

77
/** Quoted type (or kind) `T` backed by a tree */
8-
final class Type(val typeTree: tpd.Tree, val scopeId: Int) extends scala.quoted.Type[?] {
8+
final class TypeImpl(val typeTree: tpd.Tree, val scopeId: Int) extends scala.quoted.internal.Type[?] {
99
override def equals(that: Any): Boolean = that match {
10-
case that: Type => typeTree ==
10+
case that: TypeImpl => typeTree ==
1111
// TastyTreeExpr are wrappers around trees, therfore they are equals if their trees are equal.
1212
// All scopeId should be equal unless two different runs of the compiler created the trees.
1313
that.typeTree && scopeId == that.scopeId

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ object Splicer {
323323
}
324324

325325
private def interpretQuote(tree: Tree)(implicit env: Env): Object =
326-
new scala.quoted.internal.Expr(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)
326+
new dotty.tools.dotc.quoted.ExprImpl(Inlined(EmptyTree, Nil, QuoteUtils.changeOwnerOfTree(tree, ctx.owner)).withSpan(tree.span), QuoteContextImpl.scopeId)
327327

328328
private def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
329-
new scala.quoted.internal.Type(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)
329+
new dotty.tools.dotc.quoted.TypeImpl(QuoteUtils.changeOwnerOfTree(tree, ctx.owner), QuoteContextImpl.scopeId)
330330

331331
private def interpretLiteral(value: Any)(implicit env: Env): Object =
332332
value.asInstanceOf[Object]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package scala.quoted.internal
2+
3+
/** Implementation of scala.quoted.Expr that sould only be extended by the implementation of `QuoteContext` */
4+
abstract class Expr[+T] extends scala.quoted.Expr[T]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package scala.quoted.internal
2+
3+
/** Implementation of scala.quoted.Type that sould only be extended by the implementation of `QuoteContext` */
4+
abstract class Type[T <: AnyKind] extends scala.quoted.Type[T]

staging/src/scala/quoted/staging/Toolbox.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package staging
33

44
import scala.annotation.implicitNotFound
55

6-
import scala.quoted.internal.ScopeException
6+
import dotty.tools.dotc.quoted.ScopeException
77

88
@implicitNotFound("Could not find implicit scala.quoted.staging.Toolbox.\n\nDefault toolbox can be instantiated with:\n `given scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)`\n\n")
99
trait Toolbox:

0 commit comments

Comments
 (0)