Skip to content

Commit a34ddc1

Browse files
committed
---
yaml --- r: 292734 b: refs/heads/tensorflow c: 589283b h: refs/heads/master
1 parent 75b4869 commit a34ddc1

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: d4bbcc1953527ac5fa4238ec40aca08c49908ad7
819+
refs/heads/tensorflow: 589283b2c0cd1f7b6604bc5389885031fcc0dafb
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/lib/Sema/CSGen.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3274,6 +3274,38 @@ namespace {
32743274
expr = sanitizeArgumentList(expr);
32753275
}
32763276

3277+
// If this expression represents keypath based dynamic member
3278+
// lookup, let's convert it back to the original form of
3279+
// member or subscript reference.
3280+
if (auto *SE = dyn_cast<SubscriptExpr>(expr)) {
3281+
if (auto *TE = dyn_cast<TupleExpr>(SE->getIndex())) {
3282+
auto isImplicitKeyPathExpr = [](Expr *argExpr) -> bool {
3283+
if (auto *KP = dyn_cast<KeyPathExpr>(argExpr))
3284+
return KP->isImplicit();
3285+
return false;
3286+
};
3287+
3288+
if (TE->isImplicit() && TE->getNumElements() == 1 &&
3289+
TE->getElementName(0) == TC.Context.Id_dynamicMember &&
3290+
isImplicitKeyPathExpr(TE->getElement(0))) {
3291+
auto *keyPathExpr = cast<KeyPathExpr>(TE->getElement(0));
3292+
auto *componentExpr = keyPathExpr->getParsedPath();
3293+
3294+
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(componentExpr)) {
3295+
UDE->setBase(SE->getBase());
3296+
return {true, UDE};
3297+
}
3298+
3299+
if (auto *subscript = dyn_cast<SubscriptExpr>(componentExpr)) {
3300+
subscript->setBase(SE->getBase());
3301+
return {true, subscript};
3302+
}
3303+
3304+
llvm_unreachable("unknown keypath component type");
3305+
}
3306+
}
3307+
}
3308+
32773309
// Now, we're ready to walk into sub expressions.
32783310
return {true, expr};
32793311
}
@@ -3898,4 +3930,4 @@ swift::getOriginalArgumentList(Expr *expr) {
38983930
}
38993931

39003932
return result;
3901-
}
3933+
}

0 commit comments

Comments
 (0)