Skip to content

Commit df0eda9

Browse files
committed
[IDE] Update comments for access control missing set fix-its
1 parent edacf85 commit df0eda9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

include/swift/Parse/Parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ class Parser {
690690
return Context.LangOpts.EnableExperimentalConcurrency;
691691
}
692692

693-
/// Returns true if a a Swift declaration starts after the current token, otherwise returns false.
693+
/// Returns true if a Swift declaration starts after the current token,
694+
/// otherwise returns false.
694695
bool isNextStartOfSwiftDecl() {
695696
BacktrackingScope backtrack(*this);
696697
consumeToken();

lib/Parse/ParseDecl.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,9 +2922,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
29222922
// Parse the subject.
29232923
if (!Tok.isContextualKeyword("set")) {
29242924
auto diag = diagnose(Loc, diag::attr_access_expected_set, AttrName);
2925-
2926-
// Minimal recovery: if there's a single token and then an r_paren,
2927-
// consume them both. If there's just an r_paren, consume that.
2925+
29282926
if (Tok.is(tok::r_paren)) {
29292927
// Suggest `set` between empty parens e.g. `private()` -> `private(set)`
29302928
auto SetLoc = consumeToken(tok::r_paren);
@@ -2938,25 +2936,26 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
29382936
} else if (isNextStartOfSwiftDecl()) {
29392937
// Suggest `set)` in place of an invalid token after l_paren followed by
29402938
// a valid declaration start.
2941-
// e.g. `private( var x: Int` -> `private(set) var x: Int`
2942-
diag.fixItReplace(Tok.getLoc(), "set)");
2939+
// e.g. `private(<invalid> var x: Int` -> `private(set) var x: Int`
2940+
auto SetLoc = consumeToken();
2941+
diag.fixItReplace(SetLoc, "set)");
29432942
} else {
29442943
// Suggest `set)` after l_paren if not followed by a valid declaration
2945-
// e.g. `private( val x: Int` -> `private(set) val x: Int`
2944+
// e.g. `private( <invalid>` -> `private(set) <invalid>`
29462945
diag.fixItInsertAfter(LParenLoc, "set)");
29472946
}
2948-
2947+
29492948
return makeParserSuccess();
29502949
}
2951-
2950+
29522951
auto SubjectLoc = consumeToken();
29532952

29542953
AttrRange = SourceRange(Loc, Tok.getLoc());
29552954

29562955
if (!consumeIf(tok::r_paren)) {
29572956
diagnose(Loc, diag::attr_expected_rparen, AttrName,
29582957
DeclAttribute::isDeclModifier(DK))
2959-
.fixItInsertAfter(SubjectLoc, ")");
2958+
.fixItInsertAfter(SubjectLoc, ")");
29602959
return makeParserSuccess();
29612960
}
29622961

0 commit comments

Comments
 (0)