@@ -1566,32 +1566,33 @@ object Parsers {
1566
1566
def infixTypeRest (t : Tree ): Tree =
1567
1567
infixOps(t, canStartTypeTokens, refinedType, isType = true , isOperator = ! isPostfixStar)
1568
1568
1569
- /** RefinedType ::= WithType {[nl | ‘with’ ] Refinement}
1569
+ /** RefinedType ::= WithType {[nl] Refinement}
1570
1570
*/
1571
1571
val refinedType : () => Tree = () => refinedTypeRest(withType())
1572
1572
1573
- def refinedTypeRest (t : Tree ): Tree =
1573
+ def refinedTypeRest (t : Tree ): Tree = {
1574
1574
argumentStart()
1575
- if isTemplateBodyStart then
1576
- if in.token == WITH then in.nextToken()
1575
+ if (in.isNestedStart)
1577
1576
refinedTypeRest(atSpan(startOffset(t)) {
1578
1577
RefinedTypeTree (rejectWildcardType(t), refinement(indentOK = true ))
1579
1578
})
1580
1579
else t
1580
+ }
1581
1581
1582
1582
/** WithType ::= AnnotType {`with' AnnotType} (deprecated)
1583
1583
*/
1584
1584
def withType (): Tree = withTypeRest(annotType())
1585
1585
1586
1586
def withTypeRest (t : Tree ): Tree =
1587
- def isRefinementStart =
1588
- val la = in.lookahead
1589
- la.isAfterLineEnd || la.token == LBRACE
1590
- if in.token == WITH && ! isRefinementStart then
1587
+ if in.token == WITH then
1588
+ val withOffset = in.offset
1591
1589
in.nextToken()
1592
- if sourceVersion.isAtLeast(`3.1`) then
1593
- deprecationWarning(DeprecatedWithOperator ())
1594
- atSpan(startOffset(t)) { makeAndType(t, withType()) }
1590
+ if in.token == LBRACE || in.token == INDENT then
1591
+ t
1592
+ else
1593
+ if sourceVersion.isAtLeast(`3.1`) then
1594
+ deprecationWarning(DeprecatedWithOperator (), withOffset)
1595
+ atSpan(startOffset(t)) { makeAndType(t, withType()) }
1595
1596
else t
1596
1597
1597
1598
/** AnnotType ::= SimpleType {Annotation}
0 commit comments