@@ -4775,6 +4775,7 @@ class KeyPathExpr : public Expr {
47754775 OptionalChain,
47764776 OptionalWrap,
47774777 Identity,
4778+ Type,
47784779 };
47794780
47804781 private:
@@ -4871,7 +4872,17 @@ class KeyPathExpr : public Expr {
48714872 propertyType,
48724873 loc);
48734874 }
4874-
4875+
4876+ // / Create a component for a type.
4877+ static Component forType (ConcreteDeclRef typeRef,
4878+ Type type,
4879+ SourceLoc loc) {
4880+ return Component (nullptr , typeRef, nullptr , {}, {},
4881+ Kind::Type,
4882+ type,
4883+ loc);
4884+ }
4885+
48754886 // / Create a component for a subscript.
48764887 static Component forSubscript (ASTContext &ctx,
48774888 ConcreteDeclRef subscript,
@@ -4946,6 +4957,7 @@ class KeyPathExpr : public Expr {
49464957 case Kind::OptionalForce:
49474958 case Kind::Property:
49484959 case Kind::Identity:
4960+ case Kind::Type:
49494961 return true ;
49504962
49514963 case Kind::UnresolvedSubscript:
@@ -4969,6 +4981,7 @@ class KeyPathExpr : public Expr {
49694981 case Kind::UnresolvedProperty:
49704982 case Kind::Property:
49714983 case Kind::Identity:
4984+ case Kind::Type:
49724985 return nullptr ;
49734986 }
49744987 llvm_unreachable (" unhandled kind" );
@@ -4987,6 +5000,7 @@ class KeyPathExpr : public Expr {
49875000 case Kind::UnresolvedProperty:
49885001 case Kind::Property:
49895002 case Kind::Identity:
5003+ case Kind::Type:
49905004 llvm_unreachable (" no subscript labels for this kind" );
49915005 }
49925006 llvm_unreachable (" unhandled kind" );
@@ -5008,6 +5022,7 @@ class KeyPathExpr : public Expr {
50085022 case Kind::UnresolvedProperty:
50095023 case Kind::Property:
50105024 case Kind::Identity:
5025+ case Kind::Type:
50115026 return {};
50125027 }
50135028 llvm_unreachable (" unhandled kind" );
@@ -5029,6 +5044,7 @@ class KeyPathExpr : public Expr {
50295044 case Kind::OptionalForce:
50305045 case Kind::Property:
50315046 case Kind::Identity:
5047+ case Kind::Type:
50325048 llvm_unreachable (" no unresolved name for this kind" );
50335049 }
50345050 llvm_unreachable (" unhandled kind" );
@@ -5038,6 +5054,7 @@ class KeyPathExpr : public Expr {
50385054 switch (getKind ()) {
50395055 case Kind::Property:
50405056 case Kind::Subscript:
5057+ case Kind::Type:
50415058 return Decl.ResolvedDecl ;
50425059
50435060 case Kind::Invalid:
0 commit comments