@@ -1933,18 +1933,27 @@ class Typer extends Namer
1933
1933
* while tracking the quotation level in the context.
1934
1934
*/
1935
1935
def typedQuote (tree : untpd.Quote , pt : Type )(implicit ctx : Context ): Tree = track(" typedQuote" ) {
1936
- val tree1 =
1937
- if (tree.t.isType)
1938
- typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuoteR ), List (tree.t)), pt)(quoteContext)
1939
- else
1940
- typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprQuoteR ), tree.t), pt)(quoteContext)
1941
- tree1.withSpan(tree.span)
1936
+ tree.t match {
1937
+ case untpd.Splice (innerExpr) =>
1938
+ ctx.warning(" Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ." , tree.sourcePos)
1939
+ typed(innerExpr, pt)
1940
+ case t if t.isType =>
1941
+ typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuoteR ), List (tree.t)), pt)(quoteContext).withSpan(tree.span)
1942
+ case t=>
1943
+ typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprQuoteR ), tree.t), pt)(quoteContext).withSpan(tree.span)
1944
+ }
1942
1945
}
1943
1946
1944
1947
/** Translate `${ t: Expr[T] }` into expresiion `t.splice` while tracking the quotation level in the context */
1945
1948
def typedSplice (tree : untpd.Splice , pt : Type )(implicit ctx : Context ): Tree = track(" typedSplice" ) {
1946
1949
checkSpliceOutsideQuote(tree)
1947
- typedSelect(untpd.Select (tree.expr, nme.splice), pt)(spliceContext).withSpan(tree.span)
1950
+ tree.expr match {
1951
+ case untpd.Quote (innerExpr) =>
1952
+ ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
1953
+ typed(innerExpr, pt)
1954
+ case expr =>
1955
+ typedSelect(untpd.Select (expr, nme.splice), pt)(spliceContext).withSpan(tree.span)
1956
+ }
1948
1957
}
1949
1958
1950
1959
/** Translate ${ t: Type[T] }` into type `t.splice` while tracking the quotation level in the context */
0 commit comments