mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSSimplify] Produce tailored fixes for a few generic argument mismatches
- Mismatch in tuple element position should reference whole tuple with a note for mismatch position; - Situations where optional object type is not a class but matched against `AnyObject` have a tailored fix.
This commit is contained in:
@@ -6942,12 +6942,19 @@ bool ConstraintSystem::repairFailures(
|
||||
path.pop_back();
|
||||
|
||||
ConstraintFix *fix = nullptr;
|
||||
if (!path.empty() && path.back().is<LocatorPathElt::AnyRequirement>()) {
|
||||
auto *fixLoc = getConstraintLocator(anchor, path);
|
||||
|
||||
if (fixLoc->isLastElement<LocatorPathElt::AnyRequirement>()) {
|
||||
fix = fixRequirementFailure(*this, fromType, toType, anchor, path);
|
||||
} else if (fixLoc->isLastElement<LocatorPathElt::TupleElement>()) {
|
||||
return repairFailures(lhs, rhs, matchKind, flags, conversionsOrFixes,
|
||||
fixLoc);
|
||||
} else if (!lhs->mayHaveSuperclass() && rhs->isAnyObject()) {
|
||||
fix = AllowNonClassTypeToConvertToAnyObject::create(*this, fromType,
|
||||
fixLoc);
|
||||
} else {
|
||||
fix = GenericArgumentsMismatch::create(
|
||||
*this, fromType, toType, {genericArgElt.getIndex()},
|
||||
getConstraintLocator(anchor, path));
|
||||
*this, fromType, toType, {genericArgElt.getIndex()}, fixLoc);
|
||||
}
|
||||
|
||||
if (!fix)
|
||||
@@ -15687,7 +15694,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
case FixKind::AllowFunctionSpecialization:
|
||||
case FixKind::IgnoreGenericSpecializationArityMismatch:
|
||||
case FixKind::IgnoreKeyPathSubscriptIndexMismatch:
|
||||
case FixKind::AllowMemberRefOnExistential: {
|
||||
case FixKind::AllowMemberRefOnExistential:
|
||||
case FixKind::AllowNonClassTypeToConvertToAnyObject: {
|
||||
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
|
||||
}
|
||||
|
||||
@@ -15938,7 +15946,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
|
||||
case FixKind::DefaultGenericArgument:
|
||||
case FixKind::AllowMutatingMemberOnRValueBase:
|
||||
case FixKind::AllowTupleSplatForSingleParameter:
|
||||
case FixKind::AllowNonClassTypeToConvertToAnyObject:
|
||||
case FixKind::SpecifyClosureParameterType:
|
||||
case FixKind::SpecifyClosureReturnType:
|
||||
case FixKind::AddQualifierToAccessTopLevelName:
|
||||
|
||||
Reference in New Issue
Block a user