mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user