Skip to content

Commit c1618c1

Browse files
committed
[Parser] Fix suggested fix-its on enum case with empty parens
rdar://problem/58546221
1 parent 746b58e commit c1618c1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/Parse/ParsePattern.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
208208
diagnose(leftParenLoc, diagnostic)
209209
.highlight({leftParenLoc, rightParenLoc});
210210
diagnose(leftParenLoc, diag::enum_element_empty_arglist_delete)
211-
.fixItRemoveChars(leftParenLoc, rightParenLoc);
211+
.fixItRemoveChars(leftParenLoc,
212+
Lexer::getLocForEndOfToken(SourceMgr, rightParenLoc));
212213
diagnose(leftParenLoc, diag::enum_element_empty_arglist_add_void)
213-
.fixItInsert(leftParenLoc, "Void");
214+
.fixItInsertAfter(leftParenLoc, "Void");
214215
}
215216
return ParserStatus();
216217
}

test/Parse/enum.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ enum switch {} // expected-error {{keyword 'switch' cannot be used as an identif
549549

550550
enum SE0155 {
551551
case emptyArgs() // expected-warning {{enum element with associated values must have at least one associated value}}
552-
// expected-note@-1 {{did you mean to remove the empty associated value list?}} {{17-18=}}
553-
// expected-note@-2 {{did you mean to explicitly add a 'Void' associated value?}} {{17-17=Void}}
552+
// expected-note@-1 {{did you mean to remove the empty associated value list?}} {{17-19=}}
553+
// expected-note@-2 {{did you mean to explicitly add a 'Void' associated value?}} {{18-18=Void}}
554554
}
555555

556556
// SR-11261

0 commit comments

Comments
 (0)