@@ -1210,7 +1210,7 @@ object Parsers {
1210
1210
1211
1211
def expr (location : Location .Value ): Tree = {
1212
1212
val start = in.offset
1213
- if (in.token == IMPLICIT || in.token == ERASED || in.token == GIVEN ) {
1213
+ if (closureMods.contains( in.token) ) {
1214
1214
val imods = modifiers(closureMods)
1215
1215
if (in.token == MATCH ) implicitMatch(start, imods)
1216
1216
else implicitClosure(start, location, imods)
@@ -1994,11 +1994,9 @@ object Parsers {
1994
1994
normalize(loop(start))
1995
1995
}
1996
1996
1997
- /** FunArgMods ::= { `implicit` | `erased` }
1998
- * ClosureMods ::= { ‘implicit’ | ‘erased’ | ‘given’}
1997
+ /** ClosureMods ::= { ‘implicit’ | ‘erased’ | ‘given’}
1999
1998
* FunTypeMods ::= { ‘erased’ | ‘given’}
2000
1999
*/
2001
- val funArgMods : BitSet = BitSet (IMPLICIT , ERASED )
2002
2000
val closureMods : BitSet = BitSet (GIVEN , IMPLICIT , ERASED )
2003
2001
val funTypeMods : BitSet = BitSet (GIVEN , ERASED )
2004
2002
@@ -2083,11 +2081,12 @@ object Parsers {
2083
2081
def typeParamClauseOpt (ownerKind : ParamOwner .Value ): List [TypeDef ] =
2084
2082
if (in.token == LBRACKET ) typeParamClause(ownerKind) else Nil
2085
2083
2086
- /** ClsParamClause ::= [nl | ‘with’] `(' [FunArgMods] [ClsParams] ')'
2084
+ /** ClsParamClause ::= [nl] [‘erased’] ‘(’ [ClsParams] ‘)’
2085
+ * | ‘given’ [‘erased’] (‘(’ ClsParams ‘)’ | ContextTypes)
2087
2086
* ClsParams ::= ClsParam {`' ClsParam}
2088
2087
* 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)
2091
2090
* ContextTypes ::= RefinedType {`,' RefinedType}
2092
2091
* DefParams ::= DefParam {`,' DefParam}
2093
2092
* DefParam ::= {Annotation} [`inline'] Param
@@ -2158,17 +2157,10 @@ object Parsers {
2158
2157
2159
2158
// begin paramClause
2160
2159
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
2163
2161
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 () })
2172
2164
val clause =
2173
2165
if (prefix) param() :: Nil
2174
2166
else commaSeparated(() => param())
@@ -2178,22 +2170,24 @@ object Parsers {
2178
2170
}
2179
2171
}
2180
2172
2181
- /** ClsParamClauses ::= {ClsParamClause}
2182
- * DefParamClauses ::= {DefParamClause}
2183
- * InferParamClauses ::= {InferParamClause}
2173
+ /** ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
2174
+ * DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
2184
2175
*
2185
2176
* @return The parameter definitions
2186
2177
*/
2187
2178
def paramClauses (ofClass : Boolean = false ,
2188
2179
ofCaseClass : Boolean = false ,
2189
2180
ofInstance : Boolean = false ): List [List [ValDef ]] = {
2190
2181
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
+ }
2197
2191
val isContextual = initialMods.is(Given )
2198
2192
newLineOptWhenFollowedBy(LPAREN )
2199
2193
if (in.token == LPAREN ) {
@@ -2617,7 +2611,7 @@ object Parsers {
2617
2611
}
2618
2612
2619
2613
/** InstanceDef ::= [id] InstanceParams InstanceBody
2620
- * InstanceParams ::= [DefTypeParamClause] {InferParamClause }
2614
+ * InstanceParams ::= [DefTypeParamClause] {GivenParamClause }
2621
2615
* InstanceBody ::= [‘of’ ConstrApp {‘,’ ConstrApp }] [TemplateBody]
2622
2616
* | ‘of’ Type ‘=’ Expr
2623
2617
*/
@@ -2906,7 +2900,7 @@ object Parsers {
2906
2900
else if (isExprIntro)
2907
2901
stats += expr(Location .InBlock )
2908
2902
else if (isDefIntro(localModifierTokens))
2909
- if (in.token == IMPLICIT || in.token == ERASED || in.token == GIVEN ) {
2903
+ if (closureMods.contains( in.token) ) {
2910
2904
val start = in.offset
2911
2905
var imods = modifiers(closureMods)
2912
2906
if (isBindingIntro)
0 commit comments