@@ -1574,13 +1574,17 @@ object Parsers {
1574
1574
/** The block in a quote or splice */
1575
1575
def stagedBlock () = inBraces(block(simplify = true ))
1576
1576
1577
- /** SimpleExpr ::= spliceId | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1578
- * SimpleType ::= spliceId | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1577
+ /** ExprSplice ::= ‘$’ spliceId if inside quoted block
1578
+ * | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1579
+ * | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
1579
1580
*
1580
- * SimpleExpr ::= spliceId | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
1581
- * SimpleType ::= spliceId | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
1581
+ * // Deprecated syntax
1582
+ * TypeSplice ::= ‘$’ spliceId if inside quoted type
1583
+ * | ‘$’ ‘{’ Block ‘}’) unless inside quoted pattern
1584
+ * | ‘$’ ‘{’ Pattern ‘}’) when inside quoted pattern
1582
1585
*/
1583
1586
def splice (isType : Boolean ): Tree =
1587
+ val start = in.offset
1584
1588
atSpan(in.offset) {
1585
1589
val expr =
1586
1590
if (in.name.length == 1 ) {
@@ -1593,7 +1597,16 @@ object Parsers {
1593
1597
in.nextToken()
1594
1598
id
1595
1599
}
1596
- if (isType) TypSplice (expr) else Splice (expr)
1600
+ if isType then
1601
+ val msg = " Type splicing with `$` in quotes not supported anymore"
1602
+ val inPattern = (staged & StageKind .QuotedPattern ) != 0
1603
+ val hint =
1604
+ if inPattern then " Use lower cased variable name without the `$` instead"
1605
+ else " Use a given Type[T] in a quote just write T directly"
1606
+ syntaxError(s " $msg\n\n Hint: $hint" , Span (start, in.lastOffset))
1607
+ Ident (nme.ERROR .toTypeName)
1608
+ else
1609
+ Splice (expr)
1597
1610
}
1598
1611
1599
1612
/** SimpleType ::= SimpleLiteral
@@ -1637,7 +1650,7 @@ object Parsers {
1637
1650
* | Singleton `.' type
1638
1651
* | ‘(’ ArgTypes ‘)’
1639
1652
* | Refinement
1640
- * | ‘$’ ‘{’ Block ‘}’
1653
+ * | TypeSplice
1641
1654
* | SimpleType1 TypeArgs
1642
1655
* | SimpleType1 `#' id
1643
1656
*/
@@ -2239,7 +2252,7 @@ object Parsers {
2239
2252
/** SimpleExpr ::= ‘new’ ConstrApp {`with` ConstrApp} [TemplateBody]
2240
2253
* | ‘new’ TemplateBody
2241
2254
* | BlockExpr
2242
- * | ‘$’ ‘{’ Block ‘}’
2255
+ * | ExprSplice
2243
2256
* | Quoted
2244
2257
* | quoteId
2245
2258
* | SimpleExpr1 [`_`]
0 commit comments