Skip to content

Commit 4c466f2

Browse files
committed
[AST] InitAccessors: allow assignments to init accessor properties in initializers
1 parent fab9e4b commit 4c466f2

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
@@ -6755,8 +6755,17 @@ bool VarDecl::isSettable(const DeclContext *UseDC,
67556755

67566756
// If this is a 'var' decl, then we're settable if we have storage or a
67576757
// setter.
6758-
if (!isLet())
6758+
if (!isLet()) {
6759+
if (hasInitAccessor()) {
6760+
if (auto *ctor = dyn_cast_or_null<ConstructorDecl>(UseDC)) {
6761+
if (base && ctor->getImplicitSelfDecl() != base->getDecl())
6762+
return supportsMutation();
6763+
return true;
6764+
}
6765+
}
6766+
67596767
return supportsMutation();
6768+
}
67606769

67616770
// Static 'let's are always immutable.
67626771
if (isStatic()) {

0 commit comments

Comments
 (0)