@@ -1296,7 +1296,7 @@ object Parsers {
12961296
12971297 def possibleTemplateStart (isNew : Boolean = false ): Unit =
12981298 in.observeColonEOL()
1299- if in.token == COLONEOL || in.token == WITH then
1299+ if in.token == COLONEOL then
13001300 if in.lookahead.isIdent(nme.end) then in.token = NEWLINE
13011301 else
13021302 in.nextToken()
@@ -2333,7 +2333,7 @@ object Parsers {
23332333 possibleTemplateStart()
23342334 val parents =
23352335 if in.isNestedStart then Nil
2336- else constrApps(commaOK = false )
2336+ else constrApps(exclude = COMMA )
23372337 colonAtEOLOpt()
23382338 possibleTemplateStart(isNew = true )
23392339 parents match {
@@ -3536,7 +3536,7 @@ object Parsers {
35363536 val parents =
35373537 if (in.token == EXTENDS ) {
35383538 in.nextToken()
3539- constrApps(commaOK = true )
3539+ constrApps()
35403540 }
35413541 else Nil
35423542 Template (constr, parents, Nil , EmptyValDef , Nil )
@@ -3670,16 +3670,16 @@ object Parsers {
36703670
36713671 /** ConstrApps ::= ConstrApp ({‘,’ ConstrApp} | {‘with’ ConstrApp})
36723672 */
3673- def constrApps (commaOK : Boolean ): List [Tree ] =
3673+ def constrApps (exclude : Token = EMPTY ): List [Tree ] =
36743674 val t = constrApp()
36753675 val ts =
3676- if in.token == WITH || commaOK && in.token == COMMA then
3676+ val tok = in.token
3677+ if (tok == WITH || tok == COMMA ) && tok != exclude then
36773678 in.nextToken()
3678- constrApps(commaOK )
3679+ constrApps(exclude = if tok == WITH then COMMA else WITH )
36793680 else Nil
36803681 t :: ts
36813682
3682-
36833683 /** `{`with` ConstrApp} but no EOL allowed after `with`.
36843684 */
36853685 def withConstrApps (): List [Tree ] =
@@ -3704,7 +3704,7 @@ object Parsers {
37043704 in.sourcePos())
37053705 Nil
37063706 }
3707- else constrApps(commaOK = true )
3707+ else constrApps()
37083708 }
37093709 else Nil
37103710 newLinesOptWhenFollowedBy(nme.derives )
@@ -3758,8 +3758,7 @@ object Parsers {
37583758
37593759 /** with Template, with EOL <indent> interpreted */
37603760 def withTemplate (constr : DefDef , parents : List [Tree ]): Template =
3761- if in.token != WITH then syntaxError(em " `with` expected " )
3762- possibleTemplateStart() // consumes a WITH token
3761+ accept(WITH )
37633762 val (self, stats) = templateBody()
37643763 Template (constr, parents, Nil , self, stats)
37653764 .withSpan(Span (constr.span.orElse(parents.head.span).start, in.lastOffset))
0 commit comments