Skip to content

Commit 7c4662d

Browse files
committed
Use set for funArgMods
1 parent aba82ba commit 7c4662d

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ object Parsers {
721721
*/
722722
def typ(): Tree = {
723723
val start = in.offset
724-
val imods = funArgMods(EmptyModifiers)
724+
val imods = modifiers(funArgMods)
725725
def functionRest(params: List[Tree]): Tree =
726726
atPos(start, accept(ARROW)) {
727727
val t = typ()
@@ -1064,7 +1064,7 @@ object Parsers {
10641064
def expr(location: Location.Value): Tree = {
10651065
val start = in.offset
10661066
if (in.token == IMPLICIT || in.token == UNUSED) {
1067-
val imods = funArgMods(EmptyModifiers)
1067+
val imods = modifiers(funArgMods)
10681068
implicitClosure(start, location, imods)
10691069
} else {
10701070
val saved = placeholderParams
@@ -1729,14 +1729,7 @@ object Parsers {
17291729
/** FunArgMods ::= `implicit' FunArgMods
17301730
* | `unused' FunArgMods
17311731
*/
1732-
def funArgMods(imods: Modifiers, doIfImplicit: () => Unit = () => ()): Modifiers = {
1733-
if (in.token == IMPLICIT) {
1734-
doIfImplicit()
1735-
funArgMods(addMod(imods, atPos(accept(IMPLICIT)) { Mod.Implicit() }), doIfImplicit)
1736-
} else if (in.token == UNUSED)
1737-
funArgMods(addMod(imods, atPos(accept(UNUSED)) { Mod.Unused() }), doIfImplicit)
1738-
else imods
1739-
}
1732+
def funArgMods = BitSet(IMPLICIT, UNUSED)
17401733

17411734
/** Wrap annotation or constructor in New(...).<init> */
17421735
def wrapNew(tpt: Tree) = Select(New(tpt), nme.CONSTRUCTOR)
@@ -1828,7 +1821,7 @@ object Parsers {
18281821
* ClsParamClause ::= [nl] `(' [`unused'] [ClsParams] ')'
18291822
* ClsParams ::= ClsParam {`' ClsParam}
18301823
* ClsParam ::= {Annotation} [{Modifier} (`val' | `var') | `inline'] Param
1831-
* DefParamClauses ::= {DefParamClause} [[nl] `(' [`unused'] `implicit' DefParams `)']
1824+
* DefParamClauses ::= {DefParamClause} [[nl] `(' [`FunArgMods'] DefParams `)']
18321825
* DefParamClause ::= [nl] `(' [`unused'] [DefParams] ')'
18331826
* DefParams ::= DefParam {`,' DefParam}
18341827
* DefParam ::= {Annotation} [`inline'] Param
@@ -1882,8 +1875,18 @@ object Parsers {
18821875
def paramClause(): List[ValDef] = inParens {
18831876
if (in.token == RPAREN) Nil
18841877
else {
1885-
if (in.token == IMPLICIT || in.token == UNUSED)
1886-
imods = funArgMods(imods, () => implicitOffset = in.offset)
1878+
def funArgMods(): Unit = {
1879+
if (in.token == IMPLICIT) {
1880+
implicitOffset = in.offset
1881+
imods = addMod(imods, atPos(accept(IMPLICIT)) { Mod.Implicit() })
1882+
funArgMods()
1883+
} else if (in.token == UNUSED) {
1884+
imods = addMod(imods, atPos(accept(UNUSED)) { Mod.Unused() })
1885+
funArgMods()
1886+
}
1887+
}
1888+
funArgMods()
1889+
18871890
commaSeparated(() => param())
18881891
}
18891892
}
@@ -2479,7 +2482,7 @@ object Parsers {
24792482
else if (isDefIntro(localModifierTokens))
24802483
if (in.token == IMPLICIT || in.token == UNUSED) {
24812484
val start = in.offset
2482-
var imods = funArgMods(EmptyModifiers)
2485+
var imods = modifiers(funArgMods)
24832486
if (isBindingIntro) stats += implicitClosure(start, Location.InBlock, imods)
24842487
else stats +++= localDef(start, imods)
24852488
} else {

0 commit comments

Comments
 (0)