@@ -1210,7 +1210,7 @@ object Parsers {
12101210
12111211 def expr (location : Location .Value ): Tree = {
12121212 val start = in.offset
1213- if (in.token == IMPLICIT || in.token == ERASED || in.token == GIVEN ) {
1213+ if (closureMods.contains( in.token) ) {
12141214 val imods = modifiers(closureMods)
12151215 if (in.token == MATCH ) implicitMatch(start, imods)
12161216 else implicitClosure(start, location, imods)
@@ -1994,11 +1994,9 @@ object Parsers {
19941994 normalize(loop(start))
19951995 }
19961996
1997- /** FunArgMods ::= { `implicit` | `erased` }
1998- * ClosureMods ::= { ‘implicit’ | ‘erased’ | ‘given’}
1997+ /** ClosureMods ::= { ‘implicit’ | ‘erased’ | ‘given’}
19991998 * FunTypeMods ::= { ‘erased’ | ‘given’}
20001999 */
2001- val funArgMods : BitSet = BitSet (IMPLICIT , ERASED )
20022000 val closureMods : BitSet = BitSet (GIVEN , IMPLICIT , ERASED )
20032001 val funTypeMods : BitSet = BitSet (GIVEN , ERASED )
20042002
@@ -2083,11 +2081,12 @@ object Parsers {
20832081 def typeParamClauseOpt (ownerKind : ParamOwner .Value ): List [TypeDef ] =
20842082 if (in.token == LBRACKET ) typeParamClause(ownerKind) else Nil
20852083
2086- /** ClsParamClause ::= [nl | ‘with’] `(' [FunArgMods] [ClsParams] ')'
2084+ /** ClsParamClause ::= [nl] [‘erased’] ‘(’ [ClsParams] ‘)’
2085+ * | ‘given’ [‘erased’] (‘(’ ClsParams ‘)’ | ContextTypes)
20872086 * ClsParams ::= ClsParam {`' ClsParam}
20882087 * ClsParam ::= {Annotation} [{ParamModifier} (`val' | `var') | `inline'] Param
2089- * DefParamClause ::= [nl] `(' [FunArgMods] [DefParams] ')' | InferParamClause
2090- * InferParamClause ::= ‘given’ (‘(’ DefParams ‘)’ | ContextTypes)
2088+ * DefParamClause ::= [nl] [‘erased’] ‘(’ [DefParams] ‘)’ | GivenParamClause
2089+ * GivenParamClause ::= ‘given’ [‘erased’] (‘(’ DefParams ‘)’ | ContextTypes)
20912090 * ContextTypes ::= RefinedType {`,' RefinedType}
20922091 * DefParams ::= DefParam {`,' DefParam}
20932092 * DefParam ::= {Annotation} [`inline'] Param
@@ -2158,17 +2157,10 @@ object Parsers {
21582157
21592158 // begin paramClause
21602159 inParens {
2161- val isContextual = impliedMods.is(Given )
2162- if (in.token == RPAREN && ! prefix && ! isContextual) Nil
2160+ if (in.token == RPAREN && ! prefix && ! impliedMods.is(Given )) Nil
21632161 else {
2164- def funArgMods (mods : Modifiers ): Modifiers =
2165- if (in.token == IMPLICIT && ! isContextual)
2166- funArgMods(addMod(mods, atSpan(accept(IMPLICIT )) { Mod .Implicit () }))
2167- else if (in.token == ERASED )
2168- funArgMods(addMod(mods, atSpan(accept(ERASED )) { Mod .Erased () }))
2169- else mods
2170-
2171- impliedMods = funArgMods(impliedMods)
2162+ if (in.token == IMPLICIT && ! impliedMods.is(Given | Erased ))
2163+ impliedMods = addMod(impliedMods, atSpan(accept(IMPLICIT )) { Mod .Implicit () })
21722164 val clause =
21732165 if (prefix) param() :: Nil
21742166 else commaSeparated(() => param())
@@ -2178,22 +2170,24 @@ object Parsers {
21782170 }
21792171 }
21802172
2181- /** ClsParamClauses ::= {ClsParamClause}
2182- * DefParamClauses ::= {DefParamClause}
2183- * InferParamClauses ::= {InferParamClause}
2173+ /** ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
2174+ * DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
21842175 *
21852176 * @return The parameter definitions
21862177 */
21872178 def paramClauses (ofClass : Boolean = false ,
21882179 ofCaseClass : Boolean = false ,
21892180 ofInstance : Boolean = false ): List [List [ValDef ]] = {
21902181 def recur (firstClause : Boolean , nparams : Int ): List [List [ValDef ]] = {
2191- val initialMods =
2192- if (in.token == GIVEN ) {
2193- in.nextToken()
2194- Modifiers (Given | Implicit )
2195- }
2196- else EmptyModifiers
2182+ var initialMods = EmptyModifiers
2183+ if (in.token == GIVEN ) {
2184+ in.nextToken()
2185+ initialMods |= Given | Implicit
2186+ }
2187+ if (in.token == ERASED ) {
2188+ in.nextToken()
2189+ initialMods |= Erased
2190+ }
21972191 val isContextual = initialMods.is(Given )
21982192 newLineOptWhenFollowedBy(LPAREN )
21992193 if (in.token == LPAREN ) {
@@ -2617,7 +2611,7 @@ object Parsers {
26172611 }
26182612
26192613 /** InstanceDef ::= [id] InstanceParams InstanceBody
2620- * InstanceParams ::= [DefTypeParamClause] {InferParamClause }
2614+ * InstanceParams ::= [DefTypeParamClause] {GivenParamClause }
26212615 * InstanceBody ::= [‘of’ ConstrApp {‘,’ ConstrApp }] [TemplateBody]
26222616 * | ‘of’ Type ‘=’ Expr
26232617 */
@@ -2906,7 +2900,7 @@ object Parsers {
29062900 else if (isExprIntro)
29072901 stats += expr(Location .InBlock )
29082902 else if (isDefIntro(localModifierTokens))
2909- if (in.token == IMPLICIT || in.token == ERASED || in.token == GIVEN ) {
2903+ if (closureMods.contains( in.token) ) {
29102904 val start = in.offset
29112905 var imods = modifiers(closureMods)
29122906 if (isBindingIntro)
0 commit comments