@@ -3752,11 +3752,11 @@ object Parsers {
37523752 }
37533753 else Nil
37543754 possibleTemplateStart()
3755- if ( isEnum) {
3756- val (self, stats) = withinEnum(templateBody())
3755+ if isEnum then
3756+ val (self, stats) = withinEnum(templateBody(parents ))
37573757 Template (constr, parents, derived, self, stats)
3758- }
3759- else templateBodyOpt(constr, parents, derived)
3758+ else
3759+ templateBodyOpt(constr, parents, derived)
37603760 }
37613761
37623762 /** TemplateOpt = [Template]
@@ -3779,15 +3779,15 @@ object Parsers {
37793779 def templateBodyOpt (constr : DefDef , parents : List [Tree ], derived : List [Tree ]): Template =
37803780 val (self, stats) =
37813781 if in.isNestedStart then
3782- templateBody()
3782+ templateBody(parents )
37833783 else
37843784 checkNextNotIndented()
37853785 (EmptyValDef , Nil )
37863786 Template (constr, parents, derived, self, stats)
37873787
3788- def templateBody (rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
3788+ def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
37893789 val r = inDefScopeBraces(templateStatSeq(), rewriteWithColon)
3790- if in.token == WITH then
3790+ if in.token == WITH && parents.isEmpty then
37913791 syntaxError(EarlyDefinitionsNotSupported ())
37923792 in.nextToken()
37933793 template(emptyConstructor)
@@ -3796,7 +3796,7 @@ object Parsers {
37963796 /** with Template, with EOL <indent> interpreted */
37973797 def withTemplate (constr : DefDef , parents : List [Tree ]): Template =
37983798 accept(WITH )
3799- val (self, stats) = templateBody(rewriteWithColon = false )
3799+ val (self, stats) = templateBody(parents, rewriteWithColon = false )
38003800 Template (constr, parents, Nil , self, stats)
38013801 .withSpan(Span (constr.span.orElse(parents.head.span).start, in.lastOffset))
38023802
@@ -4039,7 +4039,7 @@ object Parsers {
40394039 EmptyTree
40404040 }
40414041
4042- override def templateBody (rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
4042+ override def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
40434043 skipBraces()
40444044 (EmptyValDef , List (EmptyTree ))
40454045 }
0 commit comments