@@ -1960,14 +1960,26 @@ class Typer extends Namer
1960
1960
}
1961
1961
}
1962
1962
1963
- /** Translate `'(expr)`/`'{ expr* }` into `scala.quoted.Expr.apply(expr )` and `'[T]` into `scala.quoted.Type.apply[T]`
1963
+ /** Translate '{ t }` into `scala.quoted.Expr.apply(t )` and `'[T]` into `scala.quoted.Type.apply[T]`
1964
1964
* while tracking the quotation level in the context.
1965
1965
*/
1966
1966
def typedQuote (tree : untpd.Quote , pt : Type )(implicit ctx : Context ): Tree = track(" typedQuote" ) {
1967
- if (tree.t.isType)
1968
- typedTypeApply(untpd.TypeApply (untpd.ref(defn.QuotedType_applyR ), List (tree.t)), pt)(TreeMapWithStages .quoteContext).withSpan(tree.span)
1969
- else
1970
- typedApply(untpd.Apply (untpd.ref(defn.QuotedExpr_applyR ), tree.t), pt)(TreeMapWithStages .quoteContext).withSpan(tree.span)
1967
+ val tree1 =
1968
+ if (tree.t.isType)
1969
+ typedTypeApply(untpd.TypeApply (untpd.ref(defn.QuotedType_applyR ), List (tree.t)), pt)(TreeMapWithStages .quoteContext)
1970
+ else
1971
+ typedApply(untpd.Apply (untpd.ref(defn.QuotedExpr_applyR ), tree.t), pt)(TreeMapWithStages .quoteContext)
1972
+ tree1.withSpan(tree.span)
1973
+ }
1974
+
1975
+ /** Translate `${ t: Expr[T] }` into expresiion `t.splice` while tracking the quotation level in the context */
1976
+ def typedSplice (tree : untpd.Splice , pt : Type )(implicit ctx : Context ): Tree = track(" typedSplice" ) {
1977
+ typedSelect(untpd.Select (tree.expr, nme.splice), pt)(TreeMapWithStages .spliceContext).withSpan(tree.span)
1978
+ }
1979
+
1980
+ /** Translate ${ t: Type[T] }` into type `t.splice` while tracking the quotation level in the context */
1981
+ def typedTypSplice (tree : untpd.TypSplice , pt : Type )(implicit ctx : Context ): Tree = track(" typedTypSplice" ) {
1982
+ typedSelect(untpd.Select (tree.expr, tpnme.splice), pt)(TreeMapWithStages .spliceContext).withSpan(tree.span)
1971
1983
}
1972
1984
1973
1985
/** Retrieve symbol attached to given tree */
@@ -2061,6 +2073,8 @@ class Typer extends Namer
2061
2073
case tree @ untpd.PostfixOp (qual, Ident (nme.WILDCARD )) => typedAsFunction(tree, pt)
2062
2074
case untpd.EmptyTree => tpd.EmptyTree
2063
2075
case tree : untpd.Quote => typedQuote(tree, pt)
2076
+ case tree : untpd.Splice => typedSplice(tree, pt)
2077
+ case tree : untpd.TypSplice => typedTypSplice(tree, pt)
2064
2078
case _ => typedUnadapted(desugar(tree), pt, locked)
2065
2079
}
2066
2080
0 commit comments