Skip to content

Commit 381e655

Browse files
committed
[AST] InitAccessors: allow assignments to init accessor properties in initializers
(cherry picked from commit 4c466f2)
1 parent 599e169 commit 381e655

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6818,8 +6818,17 @@ bool VarDecl::isSettable(const DeclContext *UseDC,
68186818

68196819
// If this is a 'var' decl, then we're settable if we have storage or a
68206820
// setter.
6821-
if (!isLet())
6821+
if (!isLet()) {
6822+
if (hasInitAccessor()) {
6823+
if (auto *ctor = dyn_cast_or_null<ConstructorDecl>(UseDC)) {
6824+
if (base && ctor->getImplicitSelfDecl() != base->getDecl())
6825+
return supportsMutation();
6826+
return true;
6827+
}
6828+
}
6829+
68226830
return supportsMutation();
6831+
}
68236832

68246833
// Static 'let's are always immutable.
68256834
if (isStatic()) {

0 commit comments

Comments
 (0)