@@ -5259,6 +5259,7 @@ class KeyPathExpr : public Expr {
52595259 OptionalWrap,
52605260 Identity,
52615261 TupleElement,
5262+ DictionaryKey,
52625263 };
52635264
52645265 private:
@@ -5367,6 +5368,16 @@ class KeyPathExpr : public Expr {
53675368 propertyType,
53685369 loc);
53695370 }
5371+
5372+ // / Create a component for a dictionary key (#keyPath only).
5373+ static Component forDictionaryKey (DeclNameRef UnresolvedName,
5374+ Type valueType,
5375+ SourceLoc loc) {
5376+ return Component (nullptr , UnresolvedName, nullptr , {}, {},
5377+ Kind::DictionaryKey,
5378+ valueType,
5379+ loc);
5380+ }
53705381
53715382 // / Create a component for a subscript.
53725383 static Component forSubscript (ASTContext &ctx,
@@ -5457,6 +5468,7 @@ class KeyPathExpr : public Expr {
54575468 case Kind::Property:
54585469 case Kind::Identity:
54595470 case Kind::TupleElement:
5471+ case Kind::DictionaryKey:
54605472 return true ;
54615473
54625474 case Kind::UnresolvedSubscript:
@@ -5481,6 +5493,7 @@ class KeyPathExpr : public Expr {
54815493 case Kind::Property:
54825494 case Kind::Identity:
54835495 case Kind::TupleElement:
5496+ case Kind::DictionaryKey:
54845497 return nullptr ;
54855498 }
54865499 llvm_unreachable (" unhandled kind" );
@@ -5500,6 +5513,7 @@ class KeyPathExpr : public Expr {
55005513 case Kind::Property:
55015514 case Kind::Identity:
55025515 case Kind::TupleElement:
5516+ case Kind::DictionaryKey:
55035517 llvm_unreachable (" no subscript labels for this kind" );
55045518 }
55055519 llvm_unreachable (" unhandled kind" );
@@ -5522,6 +5536,7 @@ class KeyPathExpr : public Expr {
55225536 case Kind::Property:
55235537 case Kind::Identity:
55245538 case Kind::TupleElement:
5539+ case Kind::DictionaryKey:
55255540 return {};
55265541 }
55275542 llvm_unreachable (" unhandled kind" );
@@ -5533,6 +5548,7 @@ class KeyPathExpr : public Expr {
55335548 DeclNameRef getUnresolvedDeclName () const {
55345549 switch (getKind ()) {
55355550 case Kind::UnresolvedProperty:
5551+ case Kind::DictionaryKey:
55365552 return Decl.UnresolvedName ;
55375553
55385554 case Kind::Invalid:
@@ -5563,6 +5579,7 @@ class KeyPathExpr : public Expr {
55635579 case Kind::OptionalForce:
55645580 case Kind::Identity:
55655581 case Kind::TupleElement:
5582+ case Kind::DictionaryKey:
55665583 llvm_unreachable (" no decl ref for this kind" );
55675584 }
55685585 llvm_unreachable (" unhandled kind" );
@@ -5582,6 +5599,7 @@ class KeyPathExpr : public Expr {
55825599 case Kind::Identity:
55835600 case Kind::Property:
55845601 case Kind::Subscript:
5602+ case Kind::DictionaryKey:
55855603 llvm_unreachable (" no field number for this kind" );
55865604 }
55875605 llvm_unreachable (" unhandled kind" );
0 commit comments