@@ -34,9 +34,9 @@ trait QuotesAndSplices {
34
34
/** Translate `'{ e }` into `scala.quoted.Expr.apply(e)` and `'[T]` into `scala.quoted.Type.apply[T]`
35
35
* while tracking the quotation level in the context.
36
36
*/
37
- def typedQuote (tree : untpd.Quote , pt : Type )(using Context ): Tree = {
37
+ def typedQuote (tree : untpd.QuotedExpr , pt : Type )(using Context ): Tree = {
38
38
record(" typedQuote" )
39
- tree.quoted match {
39
+ tree.expr match {
40
40
case untpd.Splice (innerExpr) if tree.isTerm && ! ctx.mode.is(Mode .Pattern ) =>
41
41
report.warning(" Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ." , tree.srcPos)
42
42
case _ =>
@@ -50,15 +50,15 @@ trait QuotesAndSplices {
50
50
51
51
if ctx.mode.is(Mode .Pattern ) then
52
52
typedQuotePattern(tree, pt, quotes).withSpan(tree.span)
53
- else if tree.quoted .isType then
53
+ else if tree.expr .isType then
54
54
val msg = em """ Quoted types `'[..]` can only be used in patterns.
55
55
|
56
56
|Hint: To get a scala.quoted.Type[T] use scala.quoted.Type.of[T] instead.
57
57
| """
58
58
report.error(msg, tree.srcPos)
59
59
EmptyTree
60
60
else
61
- val exprQuoteTree = untpd.Apply (untpd.ref(defn.QuotedRuntime_exprQuote .termRef), tree.quoted )
61
+ val exprQuoteTree = untpd.Apply (untpd.ref(defn.QuotedRuntime_exprQuote .termRef), tree.expr )
62
62
val quotedExpr = typedApply(exprQuoteTree, pt)(using quoteContext) match
63
63
case Apply (TypeApply (fn, tpt :: Nil ), quotedExpr :: Nil ) => QuotedExpr (quotedExpr, tpt)
64
64
makeInlineable(quotedExpr.select(nme.apply).appliedTo(quotes).withSpan(tree.span))
@@ -74,7 +74,7 @@ trait QuotesAndSplices {
74
74
record(" typedSplice" )
75
75
checkSpliceOutsideQuote(tree)
76
76
tree.expr match {
77
- case untpd.Quote (innerExpr) if innerExpr.isTerm =>
77
+ case untpd.QuotedExpr (innerExpr, _ ) if innerExpr.isTerm =>
78
78
report.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.srcPos)
79
79
return typed(innerExpr, pt)
80
80
case _ =>
@@ -382,13 +382,13 @@ trait QuotesAndSplices {
382
382
* ) => ...
383
383
* ```
384
384
*/
385
- private def typedQuotePattern (tree : untpd.Quote , pt : Type , qctx : Tree )(using Context ): Tree = {
386
- if tree.quoted.isTerm && ! pt.derivesFrom(defn.QuotedExprClass ) then
385
+ private def typedQuotePattern (tree : untpd.QuotedExpr , pt : Type , qctx : Tree )(using Context ): Tree = {
386
+ val quoted = tree.expr
387
+ if quoted.isTerm && ! pt.derivesFrom(defn.QuotedExprClass ) then
387
388
report.error(" Quote pattern can only match scrutinees of type scala.quoted.Expr" , tree.srcPos)
388
- else if tree. quoted.isType && ! pt.derivesFrom(defn.QuotedTypeClass ) then
389
+ else if quoted.isType && ! pt.derivesFrom(defn.QuotedTypeClass ) then
389
390
report.error(" Quote pattern can only match scrutinees of type scala.quoted.Type" , tree.srcPos)
390
391
391
- val quoted = tree.quoted
392
392
val exprPt = pt.baseType(if quoted.isType then defn.QuotedTypeClass else defn.QuotedExprClass )
393
393
val quotedPt = exprPt.argInfos.headOption match {
394
394
case Some (argPt : ValueType ) => argPt // excludes TypeBounds
@@ -440,12 +440,12 @@ trait QuotesAndSplices {
440
440
if splices.isEmpty then ref(defn.EmptyTupleModule .termRef)
441
441
else typed(untpd.Tuple (splices.map(x => untpd.TypedSplice (replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType)
442
442
443
- val quoteClass = if (tree. quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeClass
443
+ val quoteClass = if (quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeClass
444
444
val quotedPattern =
445
- if (tree. quoted.isTerm) tpd.QuotedExpr (shape, TypeTree (defn.AnyType )).select(nme.apply).appliedTo(qctx)
445
+ if (quoted.isTerm) tpd.QuotedExpr (shape, TypeTree (defn.AnyType )).select(nme.apply).appliedTo(qctx)
446
446
else ref(defn.QuotedTypeModule_of .termRef).appliedToTypeTree(shape).appliedTo(qctx)
447
447
448
- val matchModule = if tree. quoted.isTerm then defn.QuoteMatching_ExprMatch else defn.QuoteMatching_TypeMatch
448
+ val matchModule = if quoted.isTerm then defn.QuoteMatching_ExprMatch else defn.QuoteMatching_TypeMatch
449
449
val unapplyFun = qctx.asInstance(defn.QuoteMatchingClass .typeRef).select(matchModule).select(nme.unapply)
450
450
451
451
UnApply (
0 commit comments