@@ -3758,11 +3758,11 @@ object Parsers {
37583758 }
37593759 else Nil
37603760 possibleTemplateStart()
3761- if ( isEnum) {
3762- val (self, stats) = withinEnum(templateBody())
3761+ if isEnum then
3762+ val (self, stats) = withinEnum(templateBody(parents ))
37633763 Template (constr, parents, derived, self, stats)
3764- }
3765- else templateBodyOpt(constr, parents, derived)
3764+ else
3765+ templateBodyOpt(constr, parents, derived)
37663766 }
37673767
37683768 /** TemplateOpt = [Template]
@@ -3785,15 +3785,15 @@ object Parsers {
37853785 def templateBodyOpt (constr : DefDef , parents : List [Tree ], derived : List [Tree ]): Template =
37863786 val (self, stats) =
37873787 if in.isNestedStart then
3788- templateBody()
3788+ templateBody(parents )
37893789 else
37903790 checkNextNotIndented()
37913791 (EmptyValDef , Nil )
37923792 Template (constr, parents, derived, self, stats)
37933793
3794- def templateBody (rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
3794+ def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
37953795 val r = inDefScopeBraces(templateStatSeq(), rewriteWithColon)
3796- if in.token == WITH then
3796+ if in.token == WITH && parents.isEmpty then
37973797 syntaxError(EarlyDefinitionsNotSupported ())
37983798 in.nextToken()
37993799 template(emptyConstructor)
@@ -3802,7 +3802,7 @@ object Parsers {
38023802 /** with Template, with EOL <indent> interpreted */
38033803 def withTemplate (constr : DefDef , parents : List [Tree ]): Template =
38043804 accept(WITH )
3805- val (self, stats) = templateBody(rewriteWithColon = false )
3805+ val (self, stats) = templateBody(parents, rewriteWithColon = false )
38063806 Template (constr, parents, Nil , self, stats)
38073807 .withSpan(Span (constr.span.orElse(parents.head.span).start, in.lastOffset))
38083808
@@ -4045,7 +4045,7 @@ object Parsers {
40454045 EmptyTree
40464046 }
40474047
4048- override def templateBody (rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
4048+ override def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
40494049 skipBraces()
40504050 (EmptyValDef , List (EmptyTree ))
40514051 }
0 commit comments