@@ -78,8 +78,9 @@ deriveBodyKeyPathIterable_allKeyPaths(AbstractFunctionDecl *funcDecl, void *) {
78
78
auto *parentDC = funcDecl->getDeclContext ();
79
79
auto *nominal = parentDC->getSelfNominalTypeDecl ();
80
80
auto &C = nominal->getASTContext ();
81
- auto allKeyPathsInterfaceType = computeAllKeyPathsType (nominal);
82
- auto allKeyPathsType = parentDC->mapTypeIntoContext (allKeyPathsInterfaceType);
81
+ auto partialKeyPathInterfaceType = computePartialKeyPathType (nominal);
82
+ auto partialKeyPathType =
83
+ parentDC->mapTypeIntoContext (partialKeyPathInterfaceType);
83
84
84
85
auto *nominalTypeExpr = TypeExpr::createForDecl (SourceLoc (), nominal,
85
86
funcDecl, /* Implicit*/ true );
@@ -97,17 +98,17 @@ deriveBodyKeyPathIterable_allKeyPaths(AbstractFunctionDecl *funcDecl, void *) {
97
98
auto *dotExpr = new (C)
98
99
UnresolvedDotExpr (nominalTypeExpr, SourceLoc (), member->getFullName (),
99
100
DeclNameLoc (), /* Implicit*/ true );
100
- auto *keyPathExpr =
101
+ Expr *keyPathExpr =
101
102
new (C) KeyPathExpr (SourceLoc (), dotExpr, nullptr , /* Implicit*/ true );
103
+ // NOTE(TF-575): Adding an explicit coercion expression here is necessary
104
+ // due to type-checker changes.
105
+ keyPathExpr = new (C) CoerceExpr (
106
+ keyPathExpr, SourceLoc (), TypeLoc::withoutLoc (partialKeyPathType));
102
107
keyPathExprs.push_back (keyPathExpr);
103
108
}
104
109
// Return array of all key path expressions.
105
110
Expr *keyPathsArrayExpr =
106
111
ArrayExpr::create (C, SourceLoc (), keyPathExprs, {}, SourceLoc ());
107
- // NOTE(TF-575): Adding an explicit coercion expression here is necessary due
108
- // to a missing regression.
109
- keyPathsArrayExpr = new (C) CoerceExpr (
110
- keyPathsArrayExpr, SourceLoc (), TypeLoc::withoutLoc (allKeyPathsType));
111
112
auto *returnStmt = new (C) ReturnStmt (SourceLoc (), keyPathsArrayExpr);
112
113
auto *body = BraceStmt::create (C, SourceLoc (), {returnStmt}, SourceLoc (),
113
114
/* Implicit*/ true );
0 commit comments