Skip to content

Commit 2ce342b

Browse files
committed
Move internal quoted.Expr implementations to internal package
1 parent fa62051 commit 2ce342b

File tree

14 files changed

+387
-383
lines changed

14 files changed

+387
-383
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,6 @@ class Definitions {
740740
lazy val InternalQuotedMatcher_unapplyR: TermRef = InternalQuotedMatcherModule.requiredMethodRef(nme.unapply)
741741
def InternalQuotedMatcher_unapply(implicit ctx: Context) = InternalQuotedMatcher_unapplyR.symbol
742742

743-
lazy val QuotedExprsModule: TermSymbol = ctx.requiredModule("scala.quoted.Exprs")
744-
def QuotedExprsClass(implicit ctx: Context): ClassSymbol = QuotedExprsModule.asClass
745-
746743
lazy val QuotedTypeType: TypeRef = ctx.requiredClassRef("scala.quoted.Type")
747744
def QuotedTypeClass(implicit ctx: Context): ClassSymbol = QuotedTypeType.symbol.asClass
748745

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import dotty.tools.dotc.core.tasty.{PositionPickler, TastyPickler, TastyPrinter,
1616
import dotty.tools.dotc.core.tasty.TreeUnpickler.UnpickleMode
1717

1818
import scala.quoted.Types._
19-
import scala.quoted.Exprs._
19+
import scala.internal.quoted._
2020
import scala.reflect.ClassTag
2121

2222
object PickledQuotes {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import core.quoted.PickledQuotes
3434

3535
import scala.quoted
3636
import scala.quoted.Types.TreeType
37-
import scala.quoted.Exprs.TastyTreeExpr
37+
import scala.internal.quoted.TastyTreeExpr
3838
import scala.annotation.constructorOnly
3939
import scala.annotation.internal.sharable
4040

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotty.tools.dotc.quoted
33
import dotty.tools.dotc.ast.tpd
44

55
import scala.quoted._
6-
import scala.quoted.Exprs.{LiftedExpr, TastyTreeExpr}
6+
import scala.internal.quoted.{LiftedExpr, TastyTreeExpr}
77

88
/** Default runners for quoted expressions */
99
object ToolboxImpl {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
17471747
tpd.Closure(closureMethod, tss => etaExpand(new tpd.TreeOps(term).appliedToArgs(tss.head)))
17481748
case _ => term
17491749
}
1750-
new scala.quoted.Exprs.TastyTreeExpr(etaExpand(self))
1750+
new scala.internal.quoted.TastyTreeExpr(etaExpand(self))
17511751
}
17521752

17531753
/** Checked cast to a `quoted.Expr[U]` */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ object Splicer {
102102
}
103103

104104
protected def interpretQuote(tree: Tree)(implicit env: Env): Object =
105-
new scala.quoted.Exprs.TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span))
105+
new scala.internal.quoted.TastyTreeExpr(Inlined(EmptyTree, Nil, tree).withSpan(tree.span))
106106

107107
protected def interpretTypeQuote(tree: Tree)(implicit env: Env): Object =
108108
new scala.quoted.Types.TreeType(tree)
Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,54 @@
1-
package scala.quoted
1+
package scala
22

3-
import scala.runtime.quoted.Unpickler.Pickled
3+
package quoted {
44

5-
sealed abstract class Expr[+T] {
5+
sealed abstract class Expr[+T] {
66

7-
/** Evaluate the contents of this expression and return the result.
8-
*
9-
* May throw a FreeVariableError on expressions that came from a macro.
10-
*/
11-
final def run(implicit toolbox: Toolbox): T = toolbox.run(this)
7+
/** Evaluate the contents of this expression and return the result.
8+
*
9+
* May throw a FreeVariableError on expressions that came from a macro.
10+
*/
11+
final def run(implicit toolbox: Toolbox): T = toolbox.run(this)
1212

13-
}
14-
15-
/** All implementations of Expr[T].
16-
* These should never be used directly.
17-
*/
18-
object Exprs {
19-
/** An Expr backed by a pickled TASTY tree */
20-
final class TastyExpr[+T](val tasty: Pickled, val args: Seq[Any]) extends Expr[T] {
21-
override def toString: String = s"Expr(<pickled tasty>)"
2213
}
2314

24-
/** An Expr backed by a lifted value.
25-
* Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null.
26-
*/
27-
final class LiftedExpr[+T](val value: T) extends Expr[T] {
28-
override def toString: String = s"Expr($value)"
29-
}
15+
}
3016

31-
/** An Expr backed by a tree. Only the current compiler trees are allowed.
32-
*
33-
* These expressions are used for arguments of macros. They contain and actual tree
34-
* from the program that is being expanded by the macro.
35-
*
36-
* May contain references to code defined outside this TastyTreeExpr instance.
37-
*/
38-
final class TastyTreeExpr[Tree](val tree: Tree) extends quoted.Expr[Any] {
39-
override def toString: String = s"Expr(<tasty tree>)"
40-
}
17+
package internal {
18+
package quoted {
19+
20+
import scala.quoted._
21+
22+
/** An Expr backed by a pickled TASTY tree */
23+
final class TastyExpr[+T](val tasty: scala.runtime.quoted.Unpickler.Pickled, val args: Seq[Any]) extends Expr[T] {
24+
override def toString: String = s"Expr(<pickled tasty>)"
25+
}
26+
27+
/** An Expr backed by a lifted value.
28+
* Values can only be of type Boolean, Byte, Short, Char, Int, Long, Float, Double, Unit, String or Null.
29+
*/
30+
final class LiftedExpr[+T](val value: T) extends Expr[T] {
31+
override def toString: String = s"Expr($value)"
32+
}
33+
34+
/** An Expr backed by a tree. Only the current compiler trees are allowed.
35+
*
36+
* These expressions are used for arguments of macros. They contain and actual tree
37+
* from the program that is being expanded by the macro.
38+
*
39+
* May contain references to code defined outside this TastyTreeExpr instance.
40+
*/
41+
final class TastyTreeExpr[Tree](val tree: Tree) extends quoted.Expr[Any] {
42+
override def toString: String = s"Expr(<tasty tree>)"
43+
}
44+
45+
// TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]])
46+
// FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187
47+
// This test does redefine `scala.collection`. Further investigation is needed.
48+
/** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */
49+
final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] {
50+
override def toString: String = s"Expr($f <applied to> ${args.toList})"
51+
}
4152

42-
// TODO Use a List in FunctionAppliedTo(val f: Expr[_], val args: List[Expr[_]])
43-
// FIXME: Having the List in the code above trigers an assertion error while testing dotty.tools.dotc.reporting.ErrorMessagesTests.i3187
44-
// This test does redefine `scala.collection`. Further investigation is needed.
45-
/** An Expr representing `'{($f).apply($x1, ..., $xn)}` but it is beta-reduced when the closure is known */
46-
final class FunctionAppliedTo[+R](val f: Expr[_], val args: Array[Expr[_]]) extends Expr[R] {
47-
override def toString: String = s"Expr($f <applied to> ${args.toList})"
4853
}
4954
}

0 commit comments

Comments
 (0)