@@ -1071,10 +1071,20 @@ static bool parseBaseTypeForQualifiedDeclName(Parser &P, TypeRepr *&baseType) {
1071
1071
// leading period unparsed to avoid syntax verification errors.
1072
1072
assert (P.startsWithSymbol (P.Tok , ' .' ) && " false" );
1073
1073
1074
- // Check if this is a reference to an accessor in a computed property.
1075
- // FIXME: There is an ambiguity here because instead of a computed
1076
- // property with an accessor, this could be a type with a function
1077
- // name like an accessor.
1074
+ // Check if this is a reference to a property or subscript accessor.
1075
+ //
1076
+ // Note: There is an parsing ambiguity here. An accessor label identifier
1077
+ // (e.g. "set") may refer to the final declaration name component instead of
1078
+ // an accessor kind.
1079
+ //
1080
+ // FIXME: It is wrong to backtrack parsing the entire base type if an accessor
1081
+ // label is found. Instead, only the final component of the base type should
1082
+ // be backtracked. It may be best to implement this in
1083
+ // `Parser::parseTypeIdentifier`.
1084
+ //
1085
+ // Example: consider parsing `A.B.property.set`.
1086
+ // Current behavior: base type is entirely backtracked.
1087
+ // Ideal behavior: base type is parsed as `A.B`.
1078
1088
if (P.Tok .is (tok::period)) {
1079
1089
const Token &nextToken = P.peekToken ();
1080
1090
if (isAccessorLabel (nextToken).hasValue ())
@@ -1123,6 +1133,22 @@ static bool parseQualifiedDeclName(Parser &P, Diag<> nameParseError,
1123
1133
}
1124
1134
1125
1135
// Parse an optional accessor kind.
1136
+ //
1137
+ // Note: there is an parsing ambiguity here.
1138
+ //
1139
+ // Example: `A.B.property.set` may be parsed as one of the following:
1140
+ //
1141
+ // 1. No accessor kind.
1142
+ // - Base type: `A.B.property`
1143
+ // - Declaration name: `set`
1144
+ // - Accessor kind: <none>
1145
+ //
1146
+ // 2. Accessor kind exists.
1147
+ // - Base type: `A.B`
1148
+ // - Declaration name: `property`
1149
+ // - Accessor kind: `set`
1150
+ //
1151
+ // Currently, we follow (2) because it's more useful in practice.
1126
1152
if (P.Tok .is (tok::period)) {
1127
1153
const Token &nextToken = P.peekToken ();
1128
1154
Optional<AccessorKind> kind = isAccessorLabel (nextToken);
0 commit comments