@@ -1933,18 +1933,27 @@ class Typer extends Namer
19331933 * while tracking the quotation level in the context.
19341934 */
19351935 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+ }
19421945 }
19431946
19441947 /** Translate `${ t: Expr[T] }` into expresiion `t.splice` while tracking the quotation level in the context */
19451948 def typedSplice (tree : untpd.Splice , pt : Type )(implicit ctx : Context ): Tree = track(" typedSplice" ) {
19461949 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+ }
19481957 }
19491958
19501959 /** Translate ${ t: Type[T] }` into type `t.splice` while tracking the quotation level in the context */
0 commit comments