Skip to content

Commit d8582f8

Browse files
authored
Merge pull request #36804 from xedin/rdar-76187450
[CSSimplify] Add a null check to guard against broken/missing `Expres…
2 parents 368b387 + 4a94afa commit d8582f8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6216,8 +6216,11 @@ static CheckedCastKind getCheckedCastKind(ConstraintSystem *cs,
62166216
static bool isCastToExpressibleByNilLiteral(ConstraintSystem &cs, Type fromType,
62176217
Type toType) {
62186218
auto &ctx = cs.getASTContext();
6219-
auto *nilLiteral =
6220-
ctx.getProtocol(KnownProtocolKind::ExpressibleByNilLiteral);
6219+
auto *nilLiteral = TypeChecker::getProtocol(
6220+
ctx, SourceLoc(), KnownProtocolKind::ExpressibleByNilLiteral);
6221+
if (!nilLiteral)
6222+
return false;
6223+
62216224
return toType->isEqual(nilLiteral->getDeclaredType()) &&
62226225
fromType->getOptionalObjectType();
62236226
}

0 commit comments

Comments
 (0)