Skip to content

Commit 851f372

Browse files
author
Nathan Hawes
committed
[Sema] Add null checks in ConstraintSystem::bindOverloadType to prevent a crash during indexing.
locator->getAnchor() may return a null Expr*, but was being passed directly to isa<KeyPathExpr>(..) without a null check in two places. Resovles rdar://problem/63558609
1 parent f81d87a commit 851f372

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ void ConstraintSystem::bindOverloadType(
20622062

20632063
// If this is used inside of the keypath expression, we need to make
20642064
// sure that argument is Hashable.
2065-
if (isa<KeyPathExpr>(locator->getAnchor()))
2065+
if (llvm::isa_and_nonnull<KeyPathExpr>(locator->getAnchor()))
20662066
verifyThatArgumentIsHashable(0, argType, locator);
20672067

20682068
// The resolved decl is for subscript(dynamicMember:), however the original
@@ -2184,7 +2184,7 @@ void ConstraintSystem::bindOverloadType(
21842184
addConstraint(ConstraintKind::Equal, memberTy, leafTy, keyPathLoc);
21852185
}
21862186

2187-
if (isa<KeyPathExpr>(locator->getAnchor()))
2187+
if (llvm::isa_and_nonnull<KeyPathExpr>(locator->getAnchor()))
21882188
verifyThatArgumentIsHashable(0, keyPathTy, locator);
21892189

21902190
// The resolved decl is for subscript(dynamicMember:), however the

0 commit comments

Comments
 (0)