@@ -1572,13 +1572,17 @@ object Parsers {
15721572 /** The block in a quote or splice */
15731573 def stagedBlock () = inBraces(block(simplify = true ))
15741574
1575- /** SimpleExpr ::= spliceId | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1576- * SimpleType ::= spliceId | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1575+ /** ExprSplice ::= ‘$’ spliceId if inside quoted block
1576+ * | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1577+ * | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
15771578 *
1578- * SimpleExpr ::= spliceId | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
1579- * SimpleType ::= spliceId | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
1579+ * // Deprecated syntax
1580+ * TypeSplice ::= ‘$’ spliceId if inside quoted type
1581+ * | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1582+ * | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
15801583 */
15811584 def splice (isType : Boolean ): Tree =
1585+ val start = in.offset
15821586 atSpan(in.offset) {
15831587 val expr =
15841588 if (in.name.length == 1 ) {
@@ -1591,7 +1595,16 @@ object Parsers {
15911595 in.nextToken()
15921596 id
15931597 }
1594- if (isType) TypSplice (expr) else Splice (expr)
1598+ if isType then
1599+ val msg = " Type splicing with `$` in quotes not supported anymore"
1600+ val inPattern = (staged & StageKind .QuotedPattern ) != 0
1601+ val hint =
1602+ if inPattern then " Use lower cased variable name without the `$` instead"
1603+ else " Use a given Type[T] in a quote just write T directly"
1604+ syntaxError(s " $msg\n\n Hint: $hint" , Span (start, in.lastOffset))
1605+ Ident (nme.ERROR .toTypeName)
1606+ else
1607+ Splice (expr)
15951608 }
15961609
15971610 /** SimpleType ::= SimpleLiteral
@@ -1635,7 +1648,7 @@ object Parsers {
16351648 * | Singleton `.' type
16361649 * | ‘(’ ArgTypes ‘)’
16371650 * | Refinement
1638- * | ‘$’ ‘{’ Block ‘}’
1651+ * | TypeSplice
16391652 * | SimpleType1 TypeArgs
16401653 * | SimpleType1 `#' id
16411654 */
@@ -2237,7 +2250,7 @@ object Parsers {
22372250 /** SimpleExpr ::= ‘new’ ConstrApp {`with` ConstrApp} [TemplateBody]
22382251 * | ‘new’ TemplateBody
22392252 * | BlockExpr
2240- * | ‘$’ ‘{’ Block ‘}’
2253+ * | ExprSplice
22412254 * | Quoted
22422255 * | quoteId
22432256 * | SimpleExpr1 [`_`]
0 commit comments