@@ -3758,11 +3758,11 @@ object Parsers {
3758
3758
}
3759
3759
else Nil
3760
3760
possibleTemplateStart()
3761
- if ( isEnum) {
3762
- val (self, stats) = withinEnum(templateBody())
3761
+ if isEnum then
3762
+ val (self, stats) = withinEnum(templateBody(parents ))
3763
3763
Template (constr, parents, derived, self, stats)
3764
- }
3765
- else templateBodyOpt(constr, parents, derived)
3764
+ else
3765
+ templateBodyOpt(constr, parents, derived)
3766
3766
}
3767
3767
3768
3768
/** TemplateOpt = [Template]
@@ -3785,15 +3785,15 @@ object Parsers {
3785
3785
def templateBodyOpt (constr : DefDef , parents : List [Tree ], derived : List [Tree ]): Template =
3786
3786
val (self, stats) =
3787
3787
if in.isNestedStart then
3788
- templateBody()
3788
+ templateBody(parents )
3789
3789
else
3790
3790
checkNextNotIndented()
3791
3791
(EmptyValDef , Nil )
3792
3792
Template (constr, parents, derived, self, stats)
3793
3793
3794
- def templateBody (rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
3794
+ def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
3795
3795
val r = inDefScopeBraces(templateStatSeq(), rewriteWithColon)
3796
- if in.token == WITH then
3796
+ if in.token == WITH && parents.isEmpty then
3797
3797
syntaxError(EarlyDefinitionsNotSupported ())
3798
3798
in.nextToken()
3799
3799
template(emptyConstructor)
@@ -3802,7 +3802,7 @@ object Parsers {
3802
3802
/** with Template, with EOL <indent> interpreted */
3803
3803
def withTemplate (constr : DefDef , parents : List [Tree ]): Template =
3804
3804
accept(WITH )
3805
- val (self, stats) = templateBody(rewriteWithColon = false )
3805
+ val (self, stats) = templateBody(parents, rewriteWithColon = false )
3806
3806
Template (constr, parents, Nil , self, stats)
3807
3807
.withSpan(Span (constr.span.orElse(parents.head.span).start, in.lastOffset))
3808
3808
@@ -4045,7 +4045,7 @@ object Parsers {
4045
4045
EmptyTree
4046
4046
}
4047
4047
4048
- override def templateBody (rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
4048
+ override def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
4049
4049
skipBraces()
4050
4050
(EmptyValDef , List (EmptyTree ))
4051
4051
}
0 commit comments