@@ -1949,9 +1949,12 @@ class Typer extends Namer
19491949 */
19501950 def typedQuote (tree : untpd.Quote , pt : Type )(implicit ctx : Context ): Tree = track(" typedQuote" ) {
19511951 tree.quoted match {
1952- case untpd.Splice (innerExpr) =>
1952+ case untpd.Splice (innerExpr) if tree.isTerm =>
19531953 ctx.warning(" Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ." , tree.sourcePos)
19541954 typed(innerExpr, pt)
1955+ case untpd.TypSplice (innerType) if tree.isType =>
1956+ ctx.warning(" Canceled splice directly inside a quote. '[ ${ XYZ } ] is equivalent to XYZ." , tree.sourcePos)
1957+ typed(innerType, pt)
19551958 case quoted if quoted.isType =>
19561959 ctx.compilationUnit.needsStaging = true
19571960 typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuoteR ), quoted :: Nil ), pt)(quoteContext).withSpan(tree.span)
@@ -2027,7 +2030,7 @@ class Typer extends Namer
20272030 def typedSplice (tree : untpd.Splice , pt : Type )(implicit ctx : Context ): Tree = track(" typedSplice" ) {
20282031 checkSpliceOutsideQuote(tree)
20292032 tree.expr match {
2030- case untpd.Quote (innerExpr) =>
2033+ case untpd.Quote (innerExpr) if innerExpr.isTerm =>
20312034 ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
20322035 typed(innerExpr, pt)
20332036 case expr =>
@@ -2062,7 +2065,13 @@ class Typer extends Namer
20622065 def typedTypSplice (tree : untpd.TypSplice , pt : Type )(implicit ctx : Context ): Tree = track(" typedTypSplice" ) {
20632066 ctx.compilationUnit.needsStaging = true
20642067 checkSpliceOutsideQuote(tree)
2065- typedSelect(untpd.Select (tree.expr, tpnme.splice), pt)(spliceContext).withSpan(tree.span)
2068+ tree.expr match {
2069+ case untpd.Quote (innerType) if innerType.isType =>
2070+ ctx.warning(" Canceled quote directly inside a splice. ${ '[ XYZ ] } is equivalent to XYZ." , tree.sourcePos)
2071+ typed(innerType, pt)
2072+ case expr =>
2073+ typedSelect(untpd.Select (tree.expr, tpnme.splice), pt)(spliceContext).withSpan(tree.span)
2074+ }
20662075 }
20672076
20682077 private def checkSpliceOutsideQuote (tree : untpd.Tree )(implicit ctx : Context ): Unit = {
0 commit comments