mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Require CS to certify conversions associated w/ existential member accesses
This commit is contained in:
@@ -5620,6 +5620,23 @@ bool ConstraintSystem::repairFailures(
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a conversion associated with an existential member access
|
||||
// along the path, the problem is that the constraint system does not support
|
||||
// the (formally sane) upcast required to access the member.
|
||||
if (llvm::find_if(path, [](const LocatorPathElt &elt) -> bool {
|
||||
return elt.is<LocatorPathElt::ExistentialMemberAccessConversion>();
|
||||
}) != path.end()) {
|
||||
if (auto overload = findSelectedOverloadFor(castToExpr(anchor))) {
|
||||
auto &choice = overload->choice;
|
||||
conversionsOrFixes.push_back(AllowMemberRefOnExistential::create(
|
||||
*this, choice.getBaseType(), choice.getDecl(),
|
||||
DeclNameRef(choice.getDecl()->getName()),
|
||||
getConstraintLocator(locator)));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
auto elt = path.back();
|
||||
switch (elt.getKind()) {
|
||||
case ConstraintLocator::LValueConversion: {
|
||||
@@ -15153,7 +15170,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
case FixKind::GenericArgumentsMismatch:
|
||||
case FixKind::AllowConcreteTypeSpecialization:
|
||||
case FixKind::IgnoreGenericSpecializationArityMismatch:
|
||||
case FixKind::IgnoreKeyPathSubscriptIndexMismatch: {
|
||||
case FixKind::IgnoreKeyPathSubscriptIndexMismatch:
|
||||
case FixKind::AllowMemberRefOnExistential: {
|
||||
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
|
||||
}
|
||||
case FixKind::IgnoreThrownErrorMismatch: {
|
||||
@@ -15376,7 +15394,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
case FixKind::RemoveCall:
|
||||
case FixKind::RemoveUnwrap:
|
||||
case FixKind::DefineMemberBasedOnUse:
|
||||
case FixKind::AllowMemberRefOnExistential:
|
||||
case FixKind::AllowTypeOrInstanceMember:
|
||||
case FixKind::AllowInvalidPartialApplication:
|
||||
case FixKind::AllowInvalidInitRef:
|
||||
|
||||
Reference in New Issue
Block a user