@@ -5889,6 +5889,7 @@ class KeyPathExpr : public Expr {
5889
5889
public:
5890
5890
enum class Kind : unsigned {
5891
5891
Invalid,
5892
+ UnresolvedApply,
5892
5893
UnresolvedMember,
5893
5894
UnresolvedSubscript,
5894
5895
Member,
@@ -5914,13 +5915,15 @@ class KeyPathExpr : public Expr {
5914
5915
5915
5916
ArgumentList *ArgList;
5916
5917
const ProtocolConformanceRef *HashableConformancesData;
5918
+ std::optional<FunctionRefInfo> ComponentFuncRefKind;
5917
5919
5918
5920
unsigned TupleIndex;
5919
5921
Kind KindValue;
5920
5922
Type ComponentType;
5921
5923
SourceLoc Loc;
5922
5924
5923
- // Private constructor for subscript component.
5925
+ // Private constructor for unresolvedSubscript, subscript and
5926
+ // unresolvedApply component.
5924
5927
explicit Component (DeclNameOrRef decl, ArgumentList *argList,
5925
5928
ArrayRef<ProtocolConformanceRef> indexHashables,
5926
5929
Kind kind, Type type, SourceLoc loc);
@@ -5933,6 +5936,14 @@ class KeyPathExpr : public Expr {
5933
5936
Decl = decl;
5934
5937
}
5935
5938
5939
+ // Private constructor for an unresolvedMember or member kind.
5940
+ explicit Component (DeclNameOrRef decl, Kind kind, Type type,
5941
+ FunctionRefInfo funcRefKind, SourceLoc loc)
5942
+ : Decl(decl), ComponentFuncRefKind(funcRefKind), KindValue(kind),
5943
+ ComponentType(type), Loc(loc) {
5944
+ assert (kind == Kind::Member || kind == Kind::UnresolvedMember);
5945
+ }
5946
+
5936
5947
// Private constructor for tuple element kind.
5937
5948
explicit Component (unsigned tupleIndex, Type elementType, SourceLoc loc)
5938
5949
: Component(Kind::TupleElement, elementType, loc) {
@@ -5941,15 +5952,25 @@ class KeyPathExpr : public Expr {
5941
5952
5942
5953
// Private constructor for basic components with no additional information.
5943
5954
explicit Component (Kind kind, Type type, SourceLoc loc)
5944
- : Decl(), KindValue(kind), ComponentType(type), Loc(loc) {}
5955
+ : Decl(), ComponentFuncRefKind(std::nullopt), KindValue(kind),
5956
+ ComponentType(type), Loc(loc) {}
5945
5957
5946
5958
public:
5947
5959
Component () : Component(Kind::Invalid, Type(), SourceLoc()) {}
5948
5960
5949
- // / Create an unresolved component for a member.
5961
+ // / Create an unresolved component for an unresolved apply.
5962
+ static Component forUnresolvedApply (ASTContext &ctx,
5963
+ ArgumentList *argList) {
5964
+ return Component ({}, argList, {}, Kind::UnresolvedApply, Type (),
5965
+ argList->getLParenLoc ());
5966
+ };
5967
+
5968
+ // / Create an unresolved component for an unresolved member.
5950
5969
static Component forUnresolvedMember (DeclNameRef UnresolvedName,
5951
- SourceLoc Loc) {
5952
- return Component (UnresolvedName, Kind::UnresolvedMember, Type (), Loc);
5970
+ FunctionRefInfo funcRefKind,
5971
+ SourceLoc loc) {
5972
+ return Component (UnresolvedName, Kind::UnresolvedMember, Type (),
5973
+ funcRefKind, loc);
5953
5974
}
5954
5975
5955
5976
// / Create an unresolved component for a subscript.
@@ -5967,9 +5988,8 @@ class KeyPathExpr : public Expr {
5967
5988
}
5968
5989
5969
5990
// / Create a component for a property.
5970
- static Component forProperty (ConcreteDeclRef property,
5971
- Type propertyType,
5972
- SourceLoc loc) {
5991
+ static Component forMember (ConcreteDeclRef property, Type propertyType,
5992
+ SourceLoc loc) {
5973
5993
return Component (property, Kind::Member, propertyType, loc);
5974
5994
}
5975
5995
@@ -6054,6 +6074,7 @@ class KeyPathExpr : public Expr {
6054
6074
6055
6075
case Kind::UnresolvedSubscript:
6056
6076
case Kind::UnresolvedMember:
6077
+ case Kind::UnresolvedApply:
6057
6078
case Kind::Invalid:
6058
6079
case Kind::CodeCompletion:
6059
6080
return false ;
@@ -6065,6 +6086,7 @@ class KeyPathExpr : public Expr {
6065
6086
switch (getKind ()) {
6066
6087
case Kind::Subscript:
6067
6088
case Kind::UnresolvedSubscript:
6089
+ case Kind::UnresolvedApply:
6068
6090
return ArgList;
6069
6091
6070
6092
case Kind::Invalid:
@@ -6099,6 +6121,7 @@ class KeyPathExpr : public Expr {
6099
6121
case Kind::OptionalChain:
6100
6122
case Kind::OptionalWrap:
6101
6123
case Kind::OptionalForce:
6124
+ case Kind::UnresolvedApply:
6102
6125
case Kind::UnresolvedMember:
6103
6126
case Kind::Member:
6104
6127
case Kind::Identity:
@@ -6122,6 +6145,7 @@ class KeyPathExpr : public Expr {
6122
6145
case Kind::OptionalChain:
6123
6146
case Kind::OptionalWrap:
6124
6147
case Kind::OptionalForce:
6148
+ case Kind::UnresolvedApply:
6125
6149
case Kind::Member:
6126
6150
case Kind::Identity:
6127
6151
case Kind::TupleElement:
@@ -6140,6 +6164,7 @@ class KeyPathExpr : public Expr {
6140
6164
case Kind::Invalid:
6141
6165
case Kind::UnresolvedMember:
6142
6166
case Kind::UnresolvedSubscript:
6167
+ case Kind::UnresolvedApply:
6143
6168
case Kind::OptionalChain:
6144
6169
case Kind::OptionalWrap:
6145
6170
case Kind::OptionalForce:
@@ -6161,6 +6186,7 @@ class KeyPathExpr : public Expr {
6161
6186
case Kind::Invalid:
6162
6187
case Kind::UnresolvedMember:
6163
6188
case Kind::UnresolvedSubscript:
6189
+ case Kind::UnresolvedApply:
6164
6190
case Kind::OptionalChain:
6165
6191
case Kind::OptionalWrap:
6166
6192
case Kind::OptionalForce:
@@ -6181,6 +6207,7 @@ class KeyPathExpr : public Expr {
6181
6207
case Kind::Invalid:
6182
6208
case Kind::UnresolvedMember:
6183
6209
case Kind::UnresolvedSubscript:
6210
+ case Kind::UnresolvedApply:
6184
6211
case Kind::OptionalChain:
6185
6212
case Kind::OptionalWrap:
6186
6213
case Kind::OptionalForce:
@@ -6194,6 +6221,30 @@ class KeyPathExpr : public Expr {
6194
6221
llvm_unreachable (" unhandled kind" );
6195
6222
}
6196
6223
6224
+ FunctionRefInfo getFunctionRefInfo () const {
6225
+ switch (getKind ()) {
6226
+ case Kind::UnresolvedMember:
6227
+ assert (ComponentFuncRefKind &&
6228
+ " FunctionRefInfo should not be nullopt for UnresolvedMember" );
6229
+ return *ComponentFuncRefKind;
6230
+
6231
+ case Kind::Member:
6232
+ case Kind::Subscript:
6233
+ case Kind::Invalid:
6234
+ case Kind::UnresolvedSubscript:
6235
+ case Kind::OptionalChain:
6236
+ case Kind::OptionalWrap:
6237
+ case Kind::OptionalForce:
6238
+ case Kind::Identity:
6239
+ case Kind::TupleElement:
6240
+ case Kind::DictionaryKey:
6241
+ case Kind::CodeCompletion:
6242
+ case Kind::UnresolvedApply:
6243
+ llvm_unreachable (" no function ref kind for this kind" );
6244
+ }
6245
+ llvm_unreachable (" unhandled kind" );
6246
+ }
6247
+
6197
6248
Type getComponentType () const {
6198
6249
return ComponentType;
6199
6250
}
0 commit comments