Skip to content

Commit 7d6a110

Browse files
committed
[CSSimplify] Allow optional object constraint to look through holes
If right-hand side (optional type) has been determined to be a hole, let's establish that optional object of a hole is a hole and continue searching for a solution.
1 parent 1fb69a7 commit 7d6a110

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5893,6 +5893,12 @@ ConstraintSystem::simplifyOptionalObjectConstraint(
58935893
}
58945894

58955895

5896+
if (optTy->isHole()) {
5897+
if (auto *typeVar = second->getAs<TypeVariableType>())
5898+
recordPotentialHole(typeVar);
5899+
return SolutionKind::Solved;
5900+
}
5901+
58965902
Type objectTy = optTy->getOptionalObjectType();
58975903
// If the base type is not optional, let's attempt a fix (if possible)
58985904
// and assume that `!` is just not there.
@@ -10072,7 +10078,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1007210078
case FixKind::SpecifyKeyPathRootType:
1007310079
case FixKind::SpecifyLabelToAssociateTrailingClosure:
1007410080
case FixKind::AllowKeyPathWithoutComponents:
10075-
case FixKind::IgnoreInvalidFunctionBuilderBody: {
10081+
case FixKind::IgnoreInvalidFunctionBuilderBody:
10082+
case FixKind::SpecifyContextualTypeForNil: {
1007610083
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
1007710084
}
1007810085

0 commit comments

Comments
 (0)