[Typechecker] Do not incorrectly mark explicitly mutating methods as non-mutatingif we're in a class-constrained protocol extension

This commit is contained in:
Suyash Srijan
2019-10-12 02:27:26 +01:00
parent 70d77e9fe2
commit 6ca121dd2a
4 changed files with 93 additions and 7 deletions

View File

@@ -1043,6 +1043,17 @@ bool DeclContext::hasValueSemantics() const {
return false;
}
bool DeclContext::isClassConstrainedProtocolExtension() const {
if (auto ED = dyn_cast<ExtensionDecl>(this)) {
if (ED->getExtendedType()->isExistentialType()) {
return ED->getGenericSignature()->requiresClass(
ED->getSelfInterfaceType());
}
}
return false;
}
SourceLoc swift::extractNearestSourceLoc(const DeclContext *dc) {
switch (dc->getContextKind()) {
case DeclContextKind::AbstractFunctionDecl: