Sema: Subscript default arguments

Fixes <https://bugs.swift.org/browse/SR-6118>.
This commit is contained in:
Slava Pestov
2019-04-02 01:37:56 -04:00
parent 043d76a3bf
commit 6bb36b5c01
19 changed files with 308 additions and 44 deletions

View File

@@ -161,6 +161,16 @@ void constraints::simplifyLocator(Expr *&anchor,
continue;
}
if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
// The target anchor is the subscript.
targetAnchor = subscriptExpr;
targetPath.clear();
anchor = subscriptExpr->getIndex();
path = path.slice(1);
continue;
}
if (auto objectLiteralExpr = dyn_cast<ObjectLiteralExpr>(anchor)) {
targetAnchor = nullptr;
targetPath.clear();
@@ -196,6 +206,17 @@ void constraints::simplifyLocator(Expr *&anchor,
continue;
}
// The subscript itself is the function.
if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
// No additional target locator information.
targetAnchor = nullptr;
targetPath.clear();
anchor = subscriptExpr;
path = path.slice(1);
continue;
}
// The unresolved member itself is the function.
if (auto unresolvedMember = dyn_cast<UnresolvedMemberExpr>(anchor)) {
if (unresolvedMember->getArgument()) {