@@ -1037,15 +1037,14 @@ bool Parser::parseDifferentiableAttributeArguments(
1037
1037
return false ;
1038
1038
}
1039
1039
1040
- // Helper function that returns the accessorkind if a token is an accessor label.
1041
- static Optional<AccessorKind> isAccessorLabel (const Token& token) {
1040
+ // Helper function that returns the accessor kind if a token is an accessor
1041
+ // label.
1042
+ static Optional<AccessorKind> isAccessorLabel (const Token &token) {
1042
1043
if (token.is (tok::identifier)) {
1043
1044
StringRef tokText = token.getText ();
1044
- for (auto accessor : allAccessorKinds ()) {
1045
- if (tokText == getAccessorLabel (accessor)) {
1046
- return accessor;
1047
- }
1048
- }
1045
+ for (auto accessor : allAccessorKinds ())
1046
+ if (tokText == getAccessorLabel (accessor))
1047
+ return accessor;
1049
1048
}
1050
1049
return None;
1051
1050
}
@@ -1077,9 +1076,9 @@ static bool parseBaseTypeForQualifiedDeclName(Parser &P, TypeRepr *&baseType) {
1077
1076
// property with an accessor, this could be a type with a function
1078
1077
// name like an accessor.
1079
1078
if (P.Tok .is (tok::period)) {
1080
- const Token &nextToken = P.peekToken ();
1081
- if (isAccessorLabel (nextToken) != None )
1082
- return false ;
1079
+ const Token &nextToken = P.peekToken ();
1080
+ if (isAccessorLabel (nextToken). hasValue () )
1081
+ return false ;
1083
1082
}
1084
1083
1085
1084
backtrack.cancelBacktrack ();
@@ -1106,36 +1105,35 @@ static bool parseQualifiedDeclName(Parser &P, Diag<> nameParseError,
1106
1105
TypeRepr *&baseType,
1107
1106
DeclNameRefWithLoc &original) {
1108
1107
{
1109
- SyntaxParsingContext DeclNameContext (P.SyntaxContext ,
1110
- SyntaxKind::QualifiedDeclName);
1111
- // Parse base type.
1112
- if (parseBaseTypeForQualifiedDeclName (P, baseType))
1113
- return true ;
1114
- // Parse final declaration name.
1115
- original.Name = P.parseDeclNameRef (
1116
- original.Loc , nameParseError,
1117
- Parser::DeclNameFlag::AllowZeroArgCompoundNames |
1118
- Parser::DeclNameFlag::AllowKeywordsUsingSpecialNames |
1119
- Parser::DeclNameFlag::AllowOperators);
1120
- // The base type is optional, but the final unqualified declaration name is
1121
- // not. If name could not be parsed, return true for error.
1122
- if (!original.Name )
1123
- return true ;
1108
+ SyntaxParsingContext DeclNameContext (P.SyntaxContext ,
1109
+ SyntaxKind::QualifiedDeclName);
1110
+ // Parse base type.
1111
+ if (parseBaseTypeForQualifiedDeclName (P, baseType))
1112
+ return true ;
1113
+ // Parse final declaration name.
1114
+ original.Name = P.parseDeclNameRef (
1115
+ original.Loc , nameParseError,
1116
+ Parser::DeclNameFlag::AllowZeroArgCompoundNames |
1117
+ Parser::DeclNameFlag::AllowKeywordsUsingSpecialNames |
1118
+ Parser::DeclNameFlag::AllowOperators);
1119
+ // The base type is optional, but the final unqualified declaration name is
1120
+ // not. If name could not be parsed, return true for error.
1121
+ if (!original.Name )
1122
+ return true ;
1124
1123
}
1125
1124
1126
1125
// Parse an optional accessor kind.
1127
1126
if (P.Tok .is (tok::period)) {
1128
- const Token &nextToken = P.peekToken ();
1129
- Optional<AccessorKind> kind = isAccessorLabel (nextToken);
1130
- if (kind != None ) {
1131
- original.AccessorKind = kind;
1132
- P.consumeIf (tok::period);
1133
- P.consumeIf (tok::identifier);
1134
- }
1127
+ const Token &nextToken = P.peekToken ();
1128
+ Optional<AccessorKind> kind = isAccessorLabel (nextToken);
1129
+ if (kind. hasValue () ) {
1130
+ original.AccessorKind = kind;
1131
+ P.consumeIf (tok::period);
1132
+ P.consumeIf (tok::identifier);
1133
+ }
1135
1134
}
1136
1135
1137
1136
return false ;
1138
-
1139
1137
}
1140
1138
1141
1139
// / Parse a `@derivative(of:)` attribute, returning true on error.
0 commit comments