Skip to content

Commit d6d59ee

Browse files
committed
Fix TensorFlow module compilation.
Fix `KeyPathIterable` derived conformances: `KeyPathIterable.allKeyPaths` synthesis logic now uses different key-path expression coercion logic to accommodate upstream type-checker changes. See TF-575 for more information.
1 parent 8a17205 commit d6d59ee

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/Sema/DerivedConformanceKeyPathIterable.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ deriveBodyKeyPathIterable_allKeyPaths(AbstractFunctionDecl *funcDecl, void *) {
7878
auto *parentDC = funcDecl->getDeclContext();
7979
auto *nominal = parentDC->getSelfNominalTypeDecl();
8080
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);
8384

8485
auto *nominalTypeExpr = TypeExpr::createForDecl(SourceLoc(), nominal,
8586
funcDecl, /*Implicit*/ true);
@@ -97,17 +98,17 @@ deriveBodyKeyPathIterable_allKeyPaths(AbstractFunctionDecl *funcDecl, void *) {
9798
auto *dotExpr = new (C)
9899
UnresolvedDotExpr(nominalTypeExpr, SourceLoc(), member->getFullName(),
99100
DeclNameLoc(), /*Implicit*/ true);
100-
auto *keyPathExpr =
101+
Expr *keyPathExpr =
101102
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));
102107
keyPathExprs.push_back(keyPathExpr);
103108
}
104109
// Return array of all key path expressions.
105110
Expr *keyPathsArrayExpr =
106111
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));
111112
auto *returnStmt = new (C) ReturnStmt(SourceLoc(), keyPathsArrayExpr);
112113
auto *body = BraceStmt::create(C, SourceLoc(), {returnStmt}, SourceLoc(),
113114
/*Implicit*/ true);

stdlib/public/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ endif()
7373
# dependency for `numpy.ndarray` bridging to `ShapedArray`/`Tensor`.
7474
if(SWIFT_BUILD_STDLIB AND SWIFT_ENABLE_TENSORFLOW)
7575
# TODO: Add TensorFlow support for iOS/Raspberry Pi.
76-
# add_subdirectory(CTensorFlow)
77-
# add_subdirectory(TensorFlow)
76+
add_subdirectory(CTensorFlow)
77+
add_subdirectory(TensorFlow)
7878
endif()
7979

8080
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)

0 commit comments

Comments
 (0)