Skip to content

Commit 77fe850

Browse files
committed
Move TastyTreeExpr and TreeType out of the library
Now that Expr and Type are not sealed these do not need to be in the library
1 parent 95ef053 commit 77fe850

File tree

8 files changed

+20
-23
lines changed

8 files changed

+20
-23
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import dotty.tools.dotc.core.tasty.TreePickler.Hole
1515
import dotty.tools.dotc.core.tasty.{ PositionPickler, TastyPickler, TastyPrinter }
1616
import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode
1717
import dotty.tools.dotc.quoted.QuoteContext
18-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
18+
import dotty.tools.dotc.tastyreflect.{ReflectionImpl, TastyTreeExpr, TreeType}
1919

2020
import dotty.tools.tasty.TastyString
2121

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import dotty.tools.dotc.quoted.QuoteContext
3838
import dotty.tools.tasty.TastyFormat._
3939

4040
import scala.quoted
41-
import scala.internal.quoted.{TastyTreeExpr, TreeType}
41+
import dotty.tools.dotc.tastyreflect.{TastyTreeExpr, TreeType}
4242
import scala.annotation.constructorOnly
4343
import scala.annotation.internal.sharable
4444

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
3535
//
3636

3737
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): scala.quoted.Expr[?] =
38-
new scala.internal.quoted.TastyTreeExpr(PickledQuotes.unpickleExpr(repr, args), compilerId)
38+
new TastyTreeExpr(PickledQuotes.unpickleExpr(repr, args), compilerId)
3939

4040
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): scala.quoted.Type[?] =
41-
new scala.internal.quoted.TreeType(PickledQuotes.unpickleType(repr, args), compilerId)
41+
new TreeType(PickledQuotes.unpickleType(repr, args), compilerId)
4242

4343
//
4444
// CONTEXT
@@ -1779,7 +1779,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
17791779
/** Convert `Term` to an `quoted.Expr[Any]` */
17801780
def QuotedExpr_seal(self: Term)(given ctx: Context): scala.quoted.Expr[Any] = self.tpe.widen match {
17811781
case _: Types.MethodType | _: Types.PolyType => throw new Exception("Cannot seal a partially applied Term. Try eta-expanding the term first.")
1782-
case _ => new scala.internal.quoted.TastyTreeExpr(self, compilerId)
1782+
case _ => new TastyTreeExpr(self, compilerId)
17831783
}
17841784

17851785
/** Checked cast to a `quoted.Expr[U]` */
@@ -1799,7 +1799,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
17991799
/** Convert `Type` to an `quoted.Type[?]` */
18001800
def QuotedType_seal(self: Type)(given ctx: Context): scala.quoted.Type[?] = {
18011801
val dummySpan = ctx.owner.span // FIXME
1802-
new scala.internal.quoted.TreeType(tpd.TypeTree(self).withSpan(dummySpan), compilerId)
1802+
new TreeType(tpd.TypeTree(self).withSpan(dummySpan), compilerId)
18031803
}
18041804

18051805
//
@@ -1988,4 +1988,3 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
19881988

19891989
private def compilerId: Int = rootContext.outersIterator.toList.last.hashCode()
19901990
}
1991-

library/src/scala/internal/quoted/TastyTreeExpr.scala renamed to compiler/src/dotty/tools/dotc/tastyreflect/TastyTreeExpr.scala

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
package scala.internal.quoted
2-
3-
import scala.quoted.Expr
1+
package dotty.tools.dotc.tastyreflect
42

53
/** An Expr backed by a tree. Only the current compiler trees are allowed.
6-
*
7-
* These expressions are used for arguments of macros. They contain and actual tree
8-
* from the program that is being expanded by the macro.
9-
*
10-
* May contain references to code defined outside this TastyTreeExpr instance.
11-
*/
12-
final class TastyTreeExpr[Tree](val tree: Tree, val scopeId: Int) extends Expr[Any] {
4+
*
5+
* These expressions are used for arguments of macros. They contain and actual tree
6+
* from the program that is being expanded by the macro.
7+
*
8+
* May contain references to code defined outside this TastyTreeExpr instance.
9+
*/
10+
final class TastyTreeExpr[Tree](val tree: Tree, val scopeId: Int) extends scala.quoted.Expr[Any] {
1311
override def equals(that: Any): Boolean = that match {
1412
case that: TastyTreeExpr[_] =>
1513
// TastyTreeExpr are wrappers around trees, therfore they are equals if their trees are equal.

library/src/scala/internal/quoted/TreeType.scala renamed to compiler/src/dotty/tools/dotc/tastyreflect/TreeType.scala

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

33
/** An Type backed by a tree */
44
final class TreeType[Tree](val typeTree: Tree, val scopeId: Int) extends scala.quoted.Type[Any] {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import dotty.tools.dotc.core.Types._
1717
import dotty.tools.dotc.core.Symbols._
1818
import dotty.tools.dotc.core.{NameKinds, TypeErasure}
1919
import dotty.tools.dotc.core.Constants.Constant
20-
import dotty.tools.dotc.tastyreflect.ReflectionImpl
20+
import dotty.tools.dotc.tastyreflect.{ReflectionImpl, TastyTreeExpr, TreeType}
2121

2222
import scala.util.control.NonFatal
2323
import dotty.tools.dotc.util.SourcePosition
@@ -246,10 +246,10 @@ object Splicer {
246246
}
247247

248248
private def interpretQuote(tree: Tree)(implicit env: Env): Object =
249-
new scala.internal.quoted.TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span), QuoteContext.scopeId)
249+
new TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span), QuoteContext.scopeId)
250250

251251
private def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
252-
new scala.internal.quoted.TreeType(tree, QuoteContext.scopeId)
252+
new TreeType(tree, QuoteContext.scopeId)
253253

254254
private def interpretLiteral(value: Any)(implicit env: Env): Object =
255255
value.asInstanceOf[Object]

library/src/scala/quoted/Expr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted.show.SyntaxHighlight
44

55
/** Quoted expression of type `T`
66
*
7-
* Restriction: only the QuoteContext implementation is allowed to extend this trait.
7+
* Restriction: only the QuoteContext.tasty.internal implementation is allowed to extend this trait.
88
* Any other implementation will result in an undefined behavior.
99
*/
1010
trait Expr[+T] {

library/src/scala/quoted/Type.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted.show.SyntaxHighlight
44

55
/** Quoted type (or kind) `T`
66
*
7-
* Restriction: only the QuoteContext implementation is allowed to extend this trait.
7+
* Restriction: only the QuoteContext.tasty.internal implementation is allowed to extend this trait.
88
* Any other implementation will result in an undefined behavior.
99
*/
1010
trait Type[T <: AnyKind] {

0 commit comments

Comments
 (0)