Skip to content

Commit 77e1626

Browse files
committed
[Typechecker] Add a comment to explain why we return SelfAccessKind::Mutating if decl is in a class-constrained protocol extension
1 parent 09067cf commit 77e1626

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,9 @@ llvm::Expected<SelfAccessKind>
20912091
SelfAccessKindRequest::evaluate(Evaluator &evaluator, FuncDecl *FD) const {
20922092
if (FD->getAttrs().getAttribute<MutatingAttr>(true)) {
20932093
if (!FD->isInstanceMember() || !FD->getDeclContext()->hasValueSemantics()) {
2094+
// If this decl is on a class-constrained protocol extension, then
2095+
// the respect the explicit mutatingness. Otherwise, we would throw an
2096+
// error and break source compatibility.
20942097
if (FD->getDeclContext()->isClassConstrainedProtocolExtension())
20952098
return SelfAccessKind::Mutating;
20962099
return SelfAccessKind::NonMutating;

0 commit comments

Comments
 (0)