@@ -868,8 +868,6 @@ object Parsers {
868
868
while lookahead.token == LPAREN || lookahead.token == LBRACKET do
869
869
lookahead.skipParens()
870
870
lookahead.token == COLON
871
- || lookahead.token == FOR
872
- || lookahead.token == IDENTIFIER && lookahead.name == nme.as
873
871
874
872
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
875
873
@@ -2830,50 +2828,10 @@ object Parsers {
2830
2828
ofCaseClass : Boolean = false ,
2831
2829
ofInstance : Boolean = false ): List [List [ValDef ]] = {
2832
2830
2833
- /** For given instance definitions we have a disambiguation problem:
2834
- * given A as B
2835
- * given C ...
2836
- * Is the second line a parameter `given C` for the first `given` definition, or is it
2837
- * a second `given` definition? We only know if we find a `for` or `as` in `...`
2838
- * The same problem arises for
2839
- * class A
2840
- * given C ...
2841
- * For method definitions we do not have this problem since a parameter clause
2842
- * in a method definition is always followed by something else. So in
2843
- * def m(...)
2844
- * given C ...
2845
- * we know that `given` must start a parameter list. It cannot be a new given` definition.
2846
- */
2847
- def followingIsInstanceDef =
2848
- (ofClass || ofInstance) && {
2849
- val lookahead = in.LookaheadScanner () // skips newline on startup
2850
- lookahead.nextToken() // skip the `given`
2851
- if (lookahead.token == LBRACKET ) true
2852
- else {
2853
- if (lookahead.token == IDENTIFIER && lookahead.name != nme.as ||
2854
- lookahead.token == BACKQUOTED_IDENT ) {
2855
- lookahead.nextToken()
2856
- if (lookahead.token == LBRACKET ) {
2857
- lookahead.nextToken()
2858
- var openBrackets = 1
2859
- while (openBrackets > 0 && lookahead.token != EOF ) {
2860
- if (lookahead.token == LBRACKET ) openBrackets += 1
2861
- else if (lookahead.token == RBRACKET ) openBrackets -= 1
2862
- lookahead.nextToken()
2863
- }
2864
- }
2865
- }
2866
- lookahead.token == FOR ||
2867
- lookahead.token == IDENTIFIER && lookahead.name == nme.as
2868
- }
2869
- }
2870
-
2871
2831
def recur (firstClause : Boolean , nparams : Int , contextualOnly : Boolean ): List [List [ValDef ]] = {
2872
2832
var initialMods = EmptyModifiers
2873
2833
val isNewLine = in.token == NEWLINE
2874
2834
newLineOptWhenFollowedBy(LPAREN )
2875
- if (in.token == NEWLINE && in.next.token == GIVEN && allowOldGiven && ! followingIsInstanceDef)
2876
- in.nextToken()
2877
2835
if (in.token == GIVEN && allowOldGiven) {
2878
2836
in.nextToken()
2879
2837
initialMods |= Given
@@ -3406,14 +3364,8 @@ object Parsers {
3406
3364
checkExtensionParams(paramsStart, vparamss)
3407
3365
3408
3366
parseParams(isExtension = ! hasGivenSig)
3409
- var oldSyntax = false
3410
3367
val parents =
3411
- if allowOldGiven && isIdent(nme.as) then
3412
- oldSyntax = true
3413
- // for the moment, accept both `delegate for` and `given as`
3414
- in.nextToken()
3415
- tokenSeparated(COMMA , constrApp)
3416
- else if in.token == COLON then
3368
+ if in.token == COLON then
3417
3369
in.nextToken()
3418
3370
if in.token == LBRACE
3419
3371
|| in.token == LBRACKET
@@ -3427,9 +3379,6 @@ object Parsers {
3427
3379
tokenSeparated(COMMA , constrApp)
3428
3380
else Nil
3429
3381
3430
- if oldSyntax && vparamss.isEmpty then
3431
- vparamss = paramClauses(ofInstance = true )
3432
-
3433
3382
val gdef =
3434
3383
if in.token == EQUALS && parents.length == 1 && parents.head.isType then
3435
3384
in.nextToken()
0 commit comments