Merge pull request #33272 from xedin/rdar-65254452

[Diagnostics] Do more checking before recording `force downcast` fix
This commit is contained in:
Pavel Yaskevich
2020-08-04 10:22:47 -07:00
committed by GitHub
4 changed files with 30 additions and 2 deletions

View File

@@ -2968,6 +2968,9 @@ static bool
repairViaBridgingCast(ConstraintSystem &cs, Type fromType, Type toType,
SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
ConstraintLocatorBuilder locator) {
if (fromType->hasTypeVariable() || toType->hasTypeVariable())
return false;
auto objectType1 = fromType->getOptionalObjectType();
auto objectType2 = toType->getOptionalObjectType();
@@ -2986,6 +2989,9 @@ repairViaBridgingCast(ConstraintSystem &cs, Type fromType, Type toType,
if (!canBridgeThroughCast(cs, fromType, toType))
return false;
if (!TypeChecker::checkedCastMaySucceed(fromType, toType, cs.DC))
return false;
conversionsOrFixes.push_back(ForceDowncast::create(
cs, fromType, toType, cs.getConstraintLocator(locator)));
return true;