Merge pull request #58531 from xedin/rdar-92327807

[CSSimplify] Don't attempt to synthesize ~= for optional base types
This commit is contained in:
Pavel Yaskevich
2022-05-04 10:55:56 -07:00
committed by GitHub
2 changed files with 44 additions and 9 deletions

View File

@@ -9216,17 +9216,21 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
dyn_cast<EnumElementPattern>(patternLoc->getPattern())) {
auto enumType = baseObjTy->getMetatypeInstanceType();
// If the synthesis of ~= resulted in errors (i.e. broken stdlib)
// that would be diagnosed inline, so let's just fall through and
// let this situation be diagnosed as a missing member.
auto hadErrors = inferEnumMemberThroughTildeEqualsOperator(
// Optional base type does not trigger `~=` synthesis, but it tries
// to find member on both `Optional` and its wrapped type.
if (!enumType->getOptionalObjectType()) {
// If the synthesis of ~= resulted in errors (i.e. broken stdlib)
// that would be diagnosed inline, so let's just fall through and
// let this situation be diagnosed as a missing member.
auto hadErrors = inferEnumMemberThroughTildeEqualsOperator(
*this, enumElement, enumType, memberTy, locator);
// Let's consider current member constraint solved because it's
// replaced by a new set of constraints that would resolve member
// type.
if (!hadErrors)
return SolutionKind::Solved;
// Let's consider current member constraint solved because it's
// replaced by a new set of constraints that would resolve member
// type.
if (!hadErrors)
return SolutionKind::Solved;
}
}
}
}