@@ -1572,13 +1572,17 @@ object Parsers {
1572
1572
/** The block in a quote or splice */
1573
1573
def stagedBlock () = inBraces(block(simplify = true ))
1574
1574
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
1577
1578
*
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
1580
1583
*/
1581
1584
def splice (isType : Boolean ): Tree =
1585
+ val start = in.offset
1582
1586
atSpan(in.offset) {
1583
1587
val expr =
1584
1588
if (in.name.length == 1 ) {
@@ -1591,7 +1595,16 @@ object Parsers {
1591
1595
in.nextToken()
1592
1596
id
1593
1597
}
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)
1595
1608
}
1596
1609
1597
1610
/** SimpleType ::= SimpleLiteral
@@ -1635,7 +1648,7 @@ object Parsers {
1635
1648
* | Singleton `.' type
1636
1649
* | ‘(’ ArgTypes ‘)’
1637
1650
* | Refinement
1638
- * | ‘$’ ‘{’ Block ‘}’
1651
+ * | TypeSplice
1639
1652
* | SimpleType1 TypeArgs
1640
1653
* | SimpleType1 `#' id
1641
1654
*/
@@ -2237,7 +2250,7 @@ object Parsers {
2237
2250
/** SimpleExpr ::= ‘new’ ConstrApp {`with` ConstrApp} [TemplateBody]
2238
2251
* | ‘new’ TemplateBody
2239
2252
* | BlockExpr
2240
- * | ‘$’ ‘{’ Block ‘}’
2253
+ * | ExprSplice
2241
2254
* | Quoted
2242
2255
* | quoteId
2243
2256
* | SimpleExpr1 [`_`]
0 commit comments