mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Parse] Disallow space between attribute name and '(' in Swift 6 mode
This allows us to resolve disambiguities of whether a parenthesis belong to an argument to the attribute or if it is eg. the start of a tuple.
This commit is contained in:
@@ -576,6 +576,23 @@ SourceLoc Parser::getEndOfPreviousLoc() const {
|
||||
return Lexer::getLocForEndOfToken(SourceMgr, PreviousLoc);
|
||||
}
|
||||
|
||||
SourceLoc Parser::consumeAttributeLParen() {
|
||||
SourceLoc LastTokenEndLoc = getEndOfPreviousLoc();
|
||||
if (LastTokenEndLoc != Tok.getLoc() && !isInSILMode()) {
|
||||
diagnose(LastTokenEndLoc, diag::attr_extra_whitespace_before_lparen)
|
||||
.warnUntilSwiftVersion(6);
|
||||
}
|
||||
return consumeToken(tok::l_paren);
|
||||
}
|
||||
|
||||
bool Parser::consumeIfAttributeLParen() {
|
||||
if (!Tok.isFollowingLParen()) {
|
||||
return false;
|
||||
}
|
||||
consumeAttributeLParen();
|
||||
return true;
|
||||
}
|
||||
|
||||
SourceLoc Parser::consumeStartingCharacterOfCurrentToken(tok Kind, size_t Len) {
|
||||
// Consumes prefix of token and returns its location.
|
||||
// (like '?', '<', '>' or '!' immediately followed by '<')
|
||||
|
||||
Reference in New Issue
Block a user