@@ -868,8 +868,6 @@ object Parsers {
868868 while lookahead.token == LPAREN || lookahead.token == LBRACKET do
869869 lookahead.skipParens()
870870 lookahead.token == COLON
871- || lookahead.token == FOR
872- || lookahead.token == IDENTIFIER && lookahead.name == nme.as
873871
874872/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
875873
@@ -2830,50 +2828,10 @@ object Parsers {
28302828 ofCaseClass : Boolean = false ,
28312829 ofInstance : Boolean = false ): List [List [ValDef ]] = {
28322830
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-
28712831 def recur (firstClause : Boolean , nparams : Int , contextualOnly : Boolean ): List [List [ValDef ]] = {
28722832 var initialMods = EmptyModifiers
28732833 val isNewLine = in.token == NEWLINE
28742834 newLineOptWhenFollowedBy(LPAREN )
2875- if (in.token == NEWLINE && in.next.token == GIVEN && allowOldGiven && ! followingIsInstanceDef)
2876- in.nextToken()
28772835 if (in.token == GIVEN && allowOldGiven) {
28782836 in.nextToken()
28792837 initialMods |= Given
@@ -3406,14 +3364,8 @@ object Parsers {
34063364 checkExtensionParams(paramsStart, vparamss)
34073365
34083366 parseParams(isExtension = ! hasGivenSig)
3409- var oldSyntax = false
34103367 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
34173369 in.nextToken()
34183370 if in.token == LBRACE
34193371 || in.token == LBRACKET
@@ -3427,9 +3379,6 @@ object Parsers {
34273379 tokenSeparated(COMMA , constrApp)
34283380 else Nil
34293381
3430- if oldSyntax && vparamss.isEmpty then
3431- vparamss = paramClauses(ofInstance = true )
3432-
34333382 val gdef =
34343383 if in.token == EQUALS && parents.length == 1 && parents.head.isType then
34353384 in.nextToken()
0 commit comments