@@ -4944,6 +4944,7 @@ class KeyPathExpr : public Expr {
49444944 OptionalWrap,
49454945 Identity,
49464946 TupleElement,
4947+ Type,
49474948 };
49484949
49494950 private:
@@ -5052,7 +5053,17 @@ class KeyPathExpr : public Expr {
50525053 propertyType,
50535054 loc);
50545055 }
5055-
5056+
5057+ // / Create a component for a type.
5058+ static Component forType (ConcreteDeclRef typeRef,
5059+ Type type,
5060+ SourceLoc loc) {
5061+ return Component (nullptr , typeRef, nullptr , {}, {},
5062+ Kind::Type,
5063+ type,
5064+ loc);
5065+ }
5066+
50565067 // / Create a component for a subscript.
50575068 static Component forSubscript (ASTContext &ctx,
50585069 ConcreteDeclRef subscript,
@@ -5135,6 +5146,7 @@ class KeyPathExpr : public Expr {
51355146 case Kind::Property:
51365147 case Kind::Identity:
51375148 case Kind::TupleElement:
5149+ case Kind::Type:
51385150 return true ;
51395151
51405152 case Kind::UnresolvedSubscript:
@@ -5159,6 +5171,7 @@ class KeyPathExpr : public Expr {
51595171 case Kind::Property:
51605172 case Kind::Identity:
51615173 case Kind::TupleElement:
5174+ case Kind::Type:
51625175 return nullptr ;
51635176 }
51645177 llvm_unreachable (" unhandled kind" );
@@ -5178,6 +5191,7 @@ class KeyPathExpr : public Expr {
51785191 case Kind::Property:
51795192 case Kind::Identity:
51805193 case Kind::TupleElement:
5194+ case Kind::Type:
51815195 llvm_unreachable (" no subscript labels for this kind" );
51825196 }
51835197 llvm_unreachable (" unhandled kind" );
@@ -5200,6 +5214,7 @@ class KeyPathExpr : public Expr {
52005214 case Kind::Property:
52015215 case Kind::Identity:
52025216 case Kind::TupleElement:
5217+ case Kind::Type:
52035218 return {};
52045219 }
52055220 llvm_unreachable (" unhandled kind" );
@@ -5222,6 +5237,7 @@ class KeyPathExpr : public Expr {
52225237 case Kind::Property:
52235238 case Kind::Identity:
52245239 case Kind::TupleElement:
5240+ case Kind::Type:
52255241 llvm_unreachable (" no unresolved name for this kind" );
52265242 }
52275243 llvm_unreachable (" unhandled kind" );
@@ -5231,6 +5247,7 @@ class KeyPathExpr : public Expr {
52315247 switch (getKind ()) {
52325248 case Kind::Property:
52335249 case Kind::Subscript:
5250+ case Kind::Type:
52345251 return Decl.ResolvedDecl ;
52355252
52365253 case Kind::Invalid:
@@ -5260,6 +5277,7 @@ class KeyPathExpr : public Expr {
52605277 case Kind::Identity:
52615278 case Kind::Property:
52625279 case Kind::Subscript:
5280+ case Kind::Type:
52635281 llvm_unreachable (" no field number for this kind" );
52645282 }
52655283 llvm_unreachable (" unhandled kind" );
0 commit comments