File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
compiler/src/dotty/tools/dotc/core/quoted Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import scala.reflect.ClassTag
2222object PickledQuotes {
2323 import tpd ._
2424
25- /** Pickle the tree of the a quoted.Expr */
25+ /** Pickle the tree of the quoted.Expr */
2626 def pickleExpr (tree : Tree )(implicit ctx : Context ): scala.quoted.Expr [Any ] = {
2727 // Check that there are no free variables
2828 new TreeTraverser {
Original file line number Diff line number Diff line change @@ -5,7 +5,14 @@ import scala.runtime.quoted.Unpickler.Pickled
55
66sealed abstract class Expr [T ] {
77 final def unary_~ : T = throw new Error (" ~ should have been compiled away" )
8+
9+ /** Evaluate the contents of this expression and return the result.
10+ *
11+ * May throw a FreeVariableError on expressions that came from an inline macro.
12+ */
813 final def run (implicit toolbox : Toolbox [T ]): T = toolbox.run(this )
14+
15+ /** Show a source code like representation of this expression */
916 final def show (implicit toolbox : Toolbox [T ]): String = toolbox.show(this )
1017}
1118
@@ -36,7 +43,13 @@ object Exprs {
3643 override def toString : String = s " Expr( $value) "
3744 }
3845
39- /** An Expr backed by a tree. Only the current compiler trees are allowed. */
46+ /** An Expr backed by a tree. Only the current compiler trees are allowed.
47+ *
48+ * These expressions are used for arguments of inline macros. They contain and actual tree
49+ * from the program that is being expanded by the macro.
50+ *
51+ * May contain references to code defined outside this Expr instance.
52+ */
4053 final class TreeExpr [Tree ](val tree : Tree , pickle : => Expr [_]) extends quoted.Expr [Any ] {
4154 def pickled [T ]: Expr [T ] = pickle.asInstanceOf [Expr [T ]]
4255 override def toString : String = s " Expr(<raw>) "
Original file line number Diff line number Diff line change 11package scala .quoted
22
3+ /** Exception is thrown when trying to evaluate the contents of an expression
4+ * that has free variables (i.e. has some local references to code that is
5+ * outside of the expression). This can happen on Expr that passed as arguments to
6+ * an inline macro.
7+ */
38class FreeVariableError (val name : String ) extends QuoteError (" Free variable " + name + " could not be handled" )
You can’t perform that action at this time.
0 commit comments