@@ -3752,11 +3752,11 @@ object Parsers {
3752
3752
}
3753
3753
else Nil
3754
3754
possibleTemplateStart()
3755
- if ( isEnum) {
3756
- val (self, stats) = withinEnum(templateBody())
3755
+ if isEnum then
3756
+ val (self, stats) = withinEnum(templateBody(parents ))
3757
3757
Template (constr, parents, derived, self, stats)
3758
- }
3759
- else templateBodyOpt(constr, parents, derived)
3758
+ else
3759
+ templateBodyOpt(constr, parents, derived)
3760
3760
}
3761
3761
3762
3762
/** TemplateOpt = [Template]
@@ -3779,15 +3779,15 @@ object Parsers {
3779
3779
def templateBodyOpt (constr : DefDef , parents : List [Tree ], derived : List [Tree ]): Template =
3780
3780
val (self, stats) =
3781
3781
if in.isNestedStart then
3782
- templateBody()
3782
+ templateBody(parents )
3783
3783
else
3784
3784
checkNextNotIndented()
3785
3785
(EmptyValDef , Nil )
3786
3786
Template (constr, parents, derived, self, stats)
3787
3787
3788
- def templateBody (rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
3788
+ def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean = true ): (ValDef , List [Tree ]) =
3789
3789
val r = inDefScopeBraces(templateStatSeq(), rewriteWithColon)
3790
- if in.token == WITH then
3790
+ if in.token == WITH && parents.isEmpty then
3791
3791
syntaxError(EarlyDefinitionsNotSupported ())
3792
3792
in.nextToken()
3793
3793
template(emptyConstructor)
@@ -3796,7 +3796,7 @@ object Parsers {
3796
3796
/** with Template, with EOL <indent> interpreted */
3797
3797
def withTemplate (constr : DefDef , parents : List [Tree ]): Template =
3798
3798
accept(WITH )
3799
- val (self, stats) = templateBody(rewriteWithColon = false )
3799
+ val (self, stats) = templateBody(parents, rewriteWithColon = false )
3800
3800
Template (constr, parents, Nil , self, stats)
3801
3801
.withSpan(Span (constr.span.orElse(parents.head.span).start, in.lastOffset))
3802
3802
@@ -4039,7 +4039,7 @@ object Parsers {
4039
4039
EmptyTree
4040
4040
}
4041
4041
4042
- override def templateBody (rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
4042
+ override def templateBody (parents : List [ Tree ], rewriteWithColon : Boolean ): (ValDef , List [Thicket ]) = {
4043
4043
skipBraces()
4044
4044
(EmptyValDef , List (EmptyTree ))
4045
4045
}
0 commit comments