@@ -1949,9 +1949,12 @@ class Typer extends Namer
1949
1949
*/
1950
1950
def typedQuote (tree : untpd.Quote , pt : Type )(implicit ctx : Context ): Tree = track(" typedQuote" ) {
1951
1951
tree.quoted match {
1952
- case untpd.Splice (innerExpr) =>
1952
+ case untpd.Splice (innerExpr) if tree.isTerm =>
1953
1953
ctx.warning(" Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ." , tree.sourcePos)
1954
1954
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)
1955
1958
case quoted if quoted.isType =>
1956
1959
ctx.compilationUnit.needsStaging = true
1957
1960
typedTypeApply(untpd.TypeApply (untpd.ref(defn.InternalQuoted_typeQuoteR ), quoted :: Nil ), pt)(quoteContext).withSpan(tree.span)
@@ -2027,7 +2030,7 @@ class Typer extends Namer
2027
2030
def typedSplice (tree : untpd.Splice , pt : Type )(implicit ctx : Context ): Tree = track(" typedSplice" ) {
2028
2031
checkSpliceOutsideQuote(tree)
2029
2032
tree.expr match {
2030
- case untpd.Quote (innerExpr) =>
2033
+ case untpd.Quote (innerExpr) if innerExpr.isTerm =>
2031
2034
ctx.warning(" Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ." , tree.sourcePos)
2032
2035
typed(innerExpr, pt)
2033
2036
case expr =>
@@ -2062,7 +2065,13 @@ class Typer extends Namer
2062
2065
def typedTypSplice (tree : untpd.TypSplice , pt : Type )(implicit ctx : Context ): Tree = track(" typedTypSplice" ) {
2063
2066
ctx.compilationUnit.needsStaging = true
2064
2067
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
+ }
2066
2075
}
2067
2076
2068
2077
private def checkSpliceOutsideQuote (tree : untpd.Tree )(implicit ctx : Context ): Unit = {
0 commit comments