Implement super mesage sends for @objc property and subscript getters/setters.

Fixes <rdar://problem/15933008>.


Swift SVN r13100
This commit is contained in:
Doug Gregor
2014-01-29 07:45:53 +00:00
parent a2b88a798e
commit f1be1ed572
9 changed files with 83 additions and 20 deletions

View File

@@ -401,6 +401,8 @@ namespace {
auto &tc = cs.getTypeChecker();
auto &context = tc.Context;
bool isSuper = isa<SuperRefExpr>(base->getSemanticsProvidingExpr());
Type baseTy = base->getType()->getRValueType();
// Explicit member accesses are permitted to implicitly look
@@ -547,6 +549,7 @@ namespace {
= new (context) MemberRefExpr(base, dotLoc, memberRef,
memberLoc, Implicit,
IsDirectPropertyAccess);
result->setIsSuper(isSuper);
// Skip the synthesized 'self' input type of the opened type.
result->setType(simplifyType(openedType));
@@ -752,6 +755,9 @@ namespace {
auto &tc = cs.getTypeChecker();
auto baseTy = base->getType()->getRValueType();
// Check whether the base is 'super'.
bool isSuper = isa<SuperRefExpr>(base->getSemanticsProvidingExpr());
// Handle accesses that implicitly look through UncheckedOptional<T>.
if (auto objTy = cs.lookThroughUncheckedOptionalType(baseTy)) {
base = coerceUncheckedOptionalToValue(base, objTy, locator);
@@ -844,6 +850,7 @@ namespace {
subscript,
substitutions));
subscriptExpr->setType(resultTy);
subscriptExpr->setIsSuper(isSuper);
return subscriptExpr;
}
@@ -876,6 +883,7 @@ namespace {
auto *subscriptExpr
= new (tc.Context) SubscriptExpr(base, index, subscript);
subscriptExpr->setType(resultTy);
subscriptExpr->setIsSuper(isSuper);
return subscriptExpr;
}