File tree 5 files changed +18
-17
lines changed
compiler/src/dotty/tools/dotc
src/scala/internal/quoted
src-bootstrapped/scala/quoted
staging/src/scala/quoted/staging
5 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -685,8 +685,6 @@ class Definitions {
685
685
686
686
@ tu lazy val QuotedExprClass : ClassSymbol = requiredClass(" scala.quoted.Expr" )
687
687
@ tu lazy val QuotedExprModule : Symbol = QuotedExprClass .companionModule
688
- @ tu lazy val QuotedExprModule_nullExpr : Symbol = QuotedExprModule .requiredMethod(nme.nullExpr)
689
- @ tu lazy val QuotedExprModule_unitExpr : Symbol = QuotedExprModule .requiredMethod(nme.unitExpr)
690
688
691
689
@ tu lazy val QuoteContextClass : ClassSymbol = requiredClass(" scala.quoted.QuoteContext" )
692
690
@@ -716,6 +714,8 @@ class Definitions {
716
714
717
715
@ tu lazy val InternalQuotedExprModule : Symbol = requiredModule(" scala.internal.quoted.Expr" )
718
716
@ tu lazy val InternalQuotedExpr_unapply : Symbol = InternalQuotedExprModule .requiredMethod(nme.unapply)
717
+ @ tu lazy val InternalQuotedExpr_nullExpr : Symbol = InternalQuotedExprModule .requiredMethod(nme.nullExpr)
718
+ @ tu lazy val InternalQuotedExpr_unitExpr : Symbol = InternalQuotedExprModule .requiredMethod(nme.unitExpr)
719
719
720
720
@ tu lazy val InternalQuotedTypeModule : Symbol = requiredModule(" scala.internal.quoted.Type" )
721
721
@ tu lazy val InternalQuotedType_unapply : Symbol = InternalQuotedTypeModule .requiredMethod(nme.unapply)
Original file line number Diff line number Diff line change @@ -150,8 +150,8 @@ class ReifyQuotes extends MacroTransform {
150
150
def liftedValue (lifter : Symbol ) =
151
151
ref(lifter).appliedToType(originalTp).select(nme.toExpr).appliedTo(lit)
152
152
lit.const.tag match {
153
- case Constants .NullTag => ref(defn.QuotedExprModule_nullExpr )
154
- case Constants .UnitTag => ref(defn.QuotedExprModule_unitExpr )
153
+ case Constants .NullTag => ref(defn.InternalQuotedExpr_nullExpr )
154
+ case Constants .UnitTag => ref(defn.InternalQuotedExpr_unitExpr )
155
155
case Constants .BooleanTag => liftedValue(defn.LiftableModule_BooleanIsLiftable )
156
156
case Constants .ByteTag => liftedValue(defn.LiftableModule_ByteIsLiftable )
157
157
case Constants .ShortTag => liftedValue(defn.LiftableModule_ShortIsLiftable )
Original file line number Diff line number Diff line change @@ -79,18 +79,6 @@ object Expr {
79
79
case Some (expr1) => expr1.seal.asInstanceOf [Expr [T ]]
80
80
case _ => expr
81
81
82
- /** Returns a null expresssion equivalent to `'{null}` */
83
- def nullExpr : QuoteContext ?=> Expr [Null ] = qctx ?=> {
84
- import qctx .tasty ._
85
- Literal (Constant (null )).seal.asInstanceOf [Expr [Null ]]
86
- }
87
-
88
- /** Returns a unit expresssion equivalent to `'{}` or `'{()}` */
89
- def unitExpr : QuoteContext ?=> Expr [Unit ] = qctx ?=> {
90
- import qctx .tasty ._
91
- Literal (Constant (())).seal.asInstanceOf [Expr [Unit ]]
92
- }
93
-
94
82
/** Returns an expression containing a block with the given statements and ending with the expresion
95
83
* Given list of statements `s1 :: s2 :: ... :: Nil` and an expression `e` the resulting expression
96
84
* will be equivalent to `'{ $s1; $s2; ...; $e }`.
Original file line number Diff line number Diff line change @@ -55,4 +55,17 @@ object Expr {
55
55
new Matcher .QuoteMatcher [qctx.type ].termMatch(scrutineeExpr.unseal, patternExpr.unseal, hasTypeSplices).asInstanceOf [Option [Tup ]]
56
56
}
57
57
58
+
59
+ /** Returns a null expresssion equivalent to `'{null}` */
60
+ def nullExpr : QuoteContext ?=> quoted.Expr [Null ] = qctx ?=> {
61
+ import qctx .tasty ._
62
+ Literal (Constant (null )).seal.asInstanceOf [quoted.Expr [Null ]]
63
+ }
64
+
65
+ /** Returns a unit expresssion equivalent to `'{}` or `'{()}` */
66
+ def unitExpr : QuoteContext ?=> quoted.Expr [Unit ] = qctx ?=> {
67
+ import qctx .tasty ._
68
+ Literal (Constant (())).seal.asInstanceOf [quoted.Expr [Unit ]]
69
+ }
70
+
58
71
}
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ package object staging:
37
37
var result : T = noResult.asInstanceOf [T ]
38
38
def dummyRun (using QuoteContext ): Expr [Unit ] = {
39
39
result = thunk
40
- Expr .unitExpr
40
+ ' {}
41
41
}
42
42
toolbox.run(dummyRun(using _))
43
43
assert(result != noResult) // toolbox.run should have thrown an exception
You can’t perform that action at this time.
0 commit comments