Allow capturing super in explicit closures and nested functions.

The previous commit enabled this; now it's just about removing the
restriction in the parser and tightening up code completion.

Using 'super' in a closure where 'self' is captured weak or unowned still
doesn't work; the reference to 'self' within the closure is treated as
strong regardless of how it's declared. Fixing this requires a cascade of
effort, so instead I just cloned rdar://problem/19755221.

rdar://problem/14883824

Swift SVN r25065
This commit is contained in:
Jordan Rose
2015-02-07 03:56:11 +00:00
parent 492d8c365c
commit fac5a83bbf
10 changed files with 266 additions and 16 deletions

View File

@@ -1527,8 +1527,7 @@ public:
getSemanticContext(CD, Reason));
Builder.setAssociatedDecl(CD);
if (IsSuperRefExpr) {
assert(isa<ConstructorDecl>(
dyn_cast<AbstractFunctionDecl>(CurrDeclContext)) &&
assert(isa<ConstructorDecl>(CurrDeclContext) &&
"can call super.init only inside a constructor");
addLeadingDot(Builder);
Builder.addTextChunk("init");
@@ -1689,9 +1688,8 @@ public:
addConstructorCall(CD, Reason);
}
if (IsSuperRefExpr) {
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(CurrDeclContext))
if (!isa<ConstructorDecl>(AFD))
return;
if (!isa<ConstructorDecl>(CurrDeclContext))
return;
addConstructorCall(CD, Reason);
}
return;