[ConstraintSystem] Fix getEffectiveOverloadType handling of mutating methods

This commit is contained in:
Pavel Yaskevich
2024-12-16 18:57:06 -08:00
parent 95b47aead6
commit c767f7aff7

View File

@@ -1833,11 +1833,15 @@ Type ConstraintSystem::getEffectiveOverloadType(ConstraintLocator *locator,
type, var, useDC, GetClosureType{*this},
ClosureIsolatedByPreconcurrency{*this});
} else if (isa<AbstractFunctionDecl>(decl) || isa<EnumElementDecl>(decl)) {
if (decl->isInstanceMember() &&
(!overload.getBaseType() ||
(!overload.getBaseType()->getAnyNominal() &&
!overload.getBaseType()->is<ExistentialType>())))
return Type();
if (decl->isInstanceMember()) {
auto baseTy = overload.getBaseType();
if (!baseTy)
return Type();
baseTy = baseTy->getRValueType();
if (!baseTy->getAnyNominal() && !baseTy->is<ExistentialType>())
return Type();
}
// Cope with 'Self' returns.
if (!decl->getDeclContext()->getSelfProtocolDecl()) {