|
1 |
| -package scala.quoted |
| 1 | +package scala |
2 | 2 |
|
3 |
| -import scala.runtime.quoted.Unpickler.Pickled |
| 3 | +package quoted { |
4 | 4 |
|
5 |
| -sealed abstract class Expr[+T] { |
| 5 | + sealed abstract class Expr[+T] { |
6 | 6 |
|
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) |
12 | 12 |
|
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>)" |
22 | 13 | }
|
23 | 14 |
|
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 | +} |
30 | 16 |
|
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 | + } |
41 | 52 |
|
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})" |
48 | 53 | }
|
49 | 54 | }
|
0 commit comments