@@ -4861,22 +4861,28 @@ class KeyPathExpr : public Expr {
4861
4861
Expr *indexExpr,
4862
4862
ArrayRef<Identifier> subscriptLabels,
4863
4863
ArrayRef<ProtocolConformanceRef> indexHashables,
4864
- unsigned tupleIndex,
4865
4864
Kind kind,
4866
4865
Type type,
4867
4866
SourceLoc loc);
4867
+
4868
+ // Private constructor for tuple element kind
4869
+ Component (unsigned tupleIndex, Type elementType, SourceLoc loc)
4870
+ : Component(nullptr , {}, nullptr , {}, {}, Kind::TupleElement,
4871
+ elementType, loc) {
4872
+ TupleIndex = tupleIndex;
4873
+ }
4868
4874
4869
4875
public:
4870
4876
Component ()
4871
- : Component(nullptr , {}, nullptr , {}, {}, 0 , Kind::Invalid,
4877
+ : Component(nullptr , {}, nullptr , {}, {}, Kind::Invalid,
4872
4878
Type (), SourceLoc())
4873
4879
{}
4874
4880
4875
4881
// / Create an unresolved component for a property.
4876
4882
static Component forUnresolvedProperty (DeclName UnresolvedName,
4877
4883
SourceLoc Loc) {
4878
4884
return Component (nullptr ,
4879
- UnresolvedName, nullptr , {}, {}, 0 ,
4885
+ UnresolvedName, nullptr , {}, {},
4880
4886
Kind::UnresolvedProperty,
4881
4887
Type (),
4882
4888
Loc);
@@ -4902,22 +4908,22 @@ class KeyPathExpr : public Expr {
4902
4908
SourceLoc loc) {
4903
4909
4904
4910
return Component (&context,
4905
- {}, index, subscriptLabels, {}, 0 ,
4911
+ {}, index, subscriptLabels, {},
4906
4912
Kind::UnresolvedSubscript,
4907
4913
Type (), loc);
4908
4914
}
4909
4915
4910
4916
// / Create an unresolved optional force `!` component.
4911
4917
static Component forUnresolvedOptionalForce (SourceLoc BangLoc) {
4912
- return Component (nullptr , {}, nullptr , {}, {}, 0 ,
4918
+ return Component (nullptr , {}, nullptr , {}, {},
4913
4919
Kind::OptionalForce,
4914
4920
Type (),
4915
4921
BangLoc);
4916
4922
}
4917
4923
4918
4924
// / Create an unresolved optional chain `?` component.
4919
4925
static Component forUnresolvedOptionalChain (SourceLoc QuestionLoc) {
4920
- return Component (nullptr , {}, nullptr , {}, {}, 0 ,
4926
+ return Component (nullptr , {}, nullptr , {}, {},
4921
4927
Kind::OptionalChain,
4922
4928
Type (),
4923
4929
QuestionLoc);
@@ -4927,7 +4933,7 @@ class KeyPathExpr : public Expr {
4927
4933
static Component forProperty (ConcreteDeclRef property,
4928
4934
Type propertyType,
4929
4935
SourceLoc loc) {
4930
- return Component (nullptr , property, nullptr , {}, {}, 0 ,
4936
+ return Component (nullptr , property, nullptr , {}, {},
4931
4937
Kind::Property,
4932
4938
propertyType,
4933
4939
loc);
@@ -4956,15 +4962,15 @@ class KeyPathExpr : public Expr {
4956
4962
4957
4963
// / Create an optional-forcing `!` component.
4958
4964
static Component forOptionalForce (Type forcedType, SourceLoc bangLoc) {
4959
- return Component (nullptr , {}, nullptr , {}, {}, 0 ,
4965
+ return Component (nullptr , {}, nullptr , {}, {},
4960
4966
Kind::OptionalForce, forcedType,
4961
4967
bangLoc);
4962
4968
}
4963
4969
4964
4970
// / Create an optional-chaining `?` component.
4965
4971
static Component forOptionalChain (Type unwrappedType,
4966
4972
SourceLoc questionLoc) {
4967
- return Component (nullptr , {}, nullptr , {}, {}, 0 ,
4973
+ return Component (nullptr , {}, nullptr , {}, {},
4968
4974
Kind::OptionalChain, unwrappedType,
4969
4975
questionLoc);
4970
4976
}
@@ -4973,23 +4979,21 @@ class KeyPathExpr : public Expr {
4973
4979
// / syntax but may appear when the non-optional result of an optional chain
4974
4980
// / is implicitly wrapped.
4975
4981
static Component forOptionalWrap (Type wrappedType) {
4976
- return Component (nullptr , {}, nullptr , {}, {}, 0 ,
4982
+ return Component (nullptr , {}, nullptr , {}, {},
4977
4983
Kind::OptionalWrap, wrappedType,
4978
4984
SourceLoc ());
4979
4985
}
4980
4986
4981
4987
static Component forIdentity (SourceLoc selfLoc) {
4982
- return Component (nullptr , {}, nullptr , {}, {}, 0 ,
4988
+ return Component (nullptr , {}, nullptr , {}, {},
4983
4989
Kind::Identity, Type (),
4984
4990
selfLoc);
4985
4991
}
4986
4992
4987
4993
static Component forTupleElement (unsigned fieldNumber,
4988
4994
Type elementType,
4989
4995
SourceLoc loc) {
4990
- return Component (nullptr , {}, nullptr , {}, {}, fieldNumber,
4991
- Kind::TupleElement, elementType,
4992
- loc);
4996
+ return Component (fieldNumber, elementType, loc);
4993
4997
}
4994
4998
4995
4999
0 commit comments