Skip to content

Commit 3f96125

Browse files
committed
[AST] Don't compute type in ClosureExpr::capturesSelfEnablingImplictSelf
This predicate can be determined without computing the full type of the declaration.
1 parent 6fe79fa commit 3f96125

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/AST/Expr.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,8 +1968,15 @@ bool ClosureExpr::hasEmptyBody() const {
19681968
}
19691969

19701970
bool ClosureExpr::capturesSelfEnablingImplictSelf() const {
1971-
if (auto *VD = getCapturedSelfDecl())
1972-
return VD->isSelfParamCapture() && !VD->getType()->is<WeakStorageType>();
1971+
if (auto *VD = getCapturedSelfDecl()) {
1972+
if (!VD->isSelfParamCapture())
1973+
return false;
1974+
1975+
if (auto *attr = VD->getAttrs().getAttribute<ReferenceOwnershipAttr>())
1976+
return attr->get() != ReferenceOwnership::Weak;
1977+
1978+
return true;
1979+
}
19731980
return false;
19741981
}
19751982

0 commit comments

Comments
 (0)