@@ -225,7 +225,6 @@ object Parsers {
225
225
|| defIntroTokens.contains(in.token)
226
226
|| allowedMods.contains(in.token)
227
227
|| in.isSoftModifierInModifierPosition && ! excludedSoftModifiers.contains(in.name)
228
- || isIdent(nme.extension) && followingIsOldExtension()
229
228
230
229
def isStatSep : Boolean = in.isNewLine || in.token == SEMI
231
230
@@ -919,23 +918,10 @@ object Parsers {
919
918
skipParams()
920
919
lookahead.isIdent(nme.as)
921
920
922
- def followingIsNewExtension () =
921
+ def followingIsExtension () =
923
922
val next = in.lookahead.token
924
923
next == LBRACKET || next == LPAREN
925
924
926
- def followingIsOldExtension () =
927
- val lookahead = in.LookaheadScanner ()
928
- lookahead.nextToken()
929
- if lookahead.isIdent && ! lookahead.isIdent(nme.on) then
930
- lookahead.nextToken()
931
- if lookahead.isNewLine then
932
- lookahead.nextToken()
933
- lookahead.isIdent(nme.on)
934
- || lookahead.token == LBRACE
935
- || lookahead.token == COLON
936
-
937
- def followingIsExtension () = followingIsOldExtension() || followingIsNewExtension()
938
-
939
925
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
940
926
941
927
var opStack : List [OpInfo ] = Nil
@@ -1311,7 +1297,7 @@ object Parsers {
1311
1297
case stat : MemberDef if ! stat.name.isEmpty =>
1312
1298
if stat.name == nme.CONSTRUCTOR then in.token == THIS
1313
1299
else in.isIdent && in.name == stat.name.toTermName
1314
- case ModuleDef (_, Template (_, Nil , _, _)) | ExtMethods (_, _, _) =>
1300
+ case ExtMethods (_, _, _) =>
1315
1301
in.token == IDENTIFIER && in.name == nme.extension
1316
1302
case PackageDef (pid : RefTree , _) =>
1317
1303
in.isIdent && in.name == pid.name
@@ -3465,11 +3451,8 @@ object Parsers {
3465
3451
case GIVEN =>
3466
3452
givenDef(start, mods, atSpan(in.skipToken()) { Mod .Given () })
3467
3453
case _ =>
3468
- if isIdent(nme.extension) && followingIsOldExtension() then
3469
- extensionDef(start, mods)
3470
- else
3471
- syntaxErrorOrIncomplete(ExpectedStartOfTopLevelDefinition ())
3472
- EmptyTree
3454
+ syntaxErrorOrIncomplete(ExpectedStartOfTopLevelDefinition ())
3455
+ EmptyTree
3473
3456
}
3474
3457
3475
3458
/** ClassDef ::= id ClassConstr TemplateOpt
@@ -3614,28 +3597,6 @@ object Parsers {
3614
3597
finalizeDef(gdef, mods1, start)
3615
3598
}
3616
3599
3617
- /** ExtensionDef ::= [id] [‘on’ ExtParamClause {UsingParamClause}] TemplateBody
3618
- */
3619
- def extensionDef (start : Offset , mods : Modifiers ): ModuleDef =
3620
- in.nextToken()
3621
- val nameOffset = in.offset
3622
- val name = if isIdent && ! isIdent(nme.on) then ident() else EmptyTermName
3623
- val (tparams, vparamss, extensionFlag) =
3624
- if isIdent(nme.on) then
3625
- in.nextToken()
3626
- val tparams = typeParamClauseOpt(ParamOwner .Def )
3627
- val extParams = paramClause(0 , prefix = true )
3628
- val givenParamss = paramClauses(givenOnly = true )
3629
- (tparams, extParams :: givenParamss, Extension )
3630
- else
3631
- (Nil , Nil , EmptyFlags )
3632
- possibleTemplateStart()
3633
- if ! in.isNestedStart then syntaxError(" Extension without extension methods" )
3634
- val templ = templateBodyOpt(makeConstructor(tparams, vparamss), Nil , Nil )
3635
- templ.body.foreach(checkExtensionMethod(tparams, vparamss, _))
3636
- val edef = atSpan(start, nameOffset, in.offset)(ModuleDef (name, templ))
3637
- finalizeDef(edef, addFlag(mods, Given | extensionFlag), start)
3638
-
3639
3600
/** Extension ::= ‘extension’ [DefTypeParamClause] ‘(’ DefParam ‘)’
3640
3601
* {UsingParamClause} ExtMethods
3641
3602
*/
@@ -3816,7 +3777,7 @@ object Parsers {
3816
3777
stats ++= importClause(IMPORT , mkImport(outermost))
3817
3778
else if (in.token == EXPORT )
3818
3779
stats ++= importClause(EXPORT , Export .apply)
3819
- else if isIdent(nme.extension) && followingIsNewExtension () then
3780
+ else if isIdent(nme.extension) && followingIsExtension () then
3820
3781
stats += extension()
3821
3782
else if isDefIntro(modifierTokens)
3822
3783
stats +++= defOrDcl(in.offset, defAnnotsMods(modifierTokens))
@@ -3870,7 +3831,7 @@ object Parsers {
3870
3831
stats ++= importClause(IMPORT , mkImport())
3871
3832
else if (in.token == EXPORT )
3872
3833
stats ++= importClause(EXPORT , Export .apply)
3873
- else if isIdent(nme.extension) && followingIsNewExtension () then
3834
+ else if isIdent(nme.extension) && followingIsExtension () then
3874
3835
stats += extension()
3875
3836
else if (isDefIntro(modifierTokensOrCase))
3876
3837
stats +++= defOrDcl(in.offset, defAnnotsMods(modifierTokens))
@@ -3952,7 +3913,7 @@ object Parsers {
3952
3913
stats += expr(Location .InBlock )
3953
3914
else if in.token == IMPLICIT && ! in.inModifierPosition() then
3954
3915
stats += closure(in.offset, Location .InBlock , modifiers(BitSet (IMPLICIT )))
3955
- else if isIdent(nme.extension) && followingIsNewExtension () then
3916
+ else if isIdent(nme.extension) && followingIsExtension () then
3956
3917
stats += extension()
3957
3918
else if isDefIntro(localModifierTokens, excludedSoftModifiers = Set (nme.`opaque`)) then
3958
3919
stats +++= localDef(in.offset)
0 commit comments