Skip to content

Commit

Permalink
Drop with in front of template syntax
Browse files Browse the repository at this point in the history
This was no longer supported but still recognized by the parser
  • Loading branch information
odersky committed Nov 25, 2020
1 parent dbbf588 commit 1ec425a
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@ object Parsers {
possibleTemplateStart()
val parents =
if in.isNestedStart then Nil
else constrApps(commaOK = false, templateCanFollow = true)
else constrApps(commaOK = false)
colonAtEOLOpt()
possibleTemplateStart(isNew = true)
parents match {
Expand Down Expand Up @@ -3493,7 +3493,7 @@ object Parsers {
val parents =
if (in.token == EXTENDS) {
in.nextToken()
constrApps(commaOK = true, templateCanFollow = false)
constrApps(commaOK = true)
}
else Nil
Template(constr, parents, Nil, EmptyValDef, Nil)
Expand Down Expand Up @@ -3537,7 +3537,7 @@ object Parsers {
val noParams = tparams.isEmpty && vparamss.isEmpty
if !(name.isEmpty && noParams) then
accept(nme.as)
val parents = constrApps(commaOK = true, templateCanFollow = true)
val parents = constrApps(commaOK = true)
if in.token == EQUALS && parents.length == 1 && parents.head.isType then
accept(EQUALS)
mods1 |= Final
Expand Down Expand Up @@ -3617,19 +3617,12 @@ object Parsers {

/** ConstrApps ::= ConstrApp {(‘,’ | ‘with’) ConstrApp}
*/
def constrApps(commaOK: Boolean, templateCanFollow: Boolean): List[Tree] =
def constrApps(commaOK: Boolean): List[Tree] =
val t = constrApp()
val ts =
if in.token == WITH then
if in.token == WITH || commaOK && in.token == COMMA then
in.nextToken()
newLineOptWhenFollowedBy(LBRACE)
if templateCanFollow && (in.token == LBRACE || in.token == INDENT) then
Nil
else
constrApps(commaOK, templateCanFollow)
else if commaOK && in.token == COMMA then
in.nextToken()
constrApps(commaOK, templateCanFollow)
constrApps(commaOK)
else Nil
t :: ts

Expand All @@ -3646,7 +3639,7 @@ object Parsers {
in.sourcePos())
Nil
}
else constrApps(commaOK = true, templateCanFollow = true)
else constrApps(commaOK = true)
}
else Nil
newLinesOptWhenFollowedBy(nme.derives)
Expand Down

0 comments on commit 1ec425a

Please sign in to comment.