Skip to content

Commit 606d55b

Browse files
authored
[CSSimplify] Guard against null locator in isSelfRecursiveKeyPathDynamicMemberLookup (#29889)
1 parent 377b703 commit 606d55b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5336,7 +5336,8 @@ static bool isSelfRecursiveKeyPathDynamicMemberLookup(
53365336
ConstraintSystem &cs, Type keyPathRootTy, ConstraintLocator *locator) {
53375337
// Let's check whether this is a recursive call to keypath
53385338
// dynamic member lookup on the same type.
5339-
if (!locator->isLastElement<LocatorPathElt::KeyPathDynamicMember>())
5339+
if (!locator ||
5340+
!locator->isLastElement<LocatorPathElt::KeyPathDynamicMember>())
53405341
return false;
53415342

53425343
auto path = locator->getPath();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Ensure that we don't crash looking for default implementations during indexing.
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s -verify
5+
6+
@dynamicMemberLookup
7+
public protocol Foo {
8+
associatedtype Value
9+
10+
var value: Value { get }
11+
subscript<U>(dynamicMember keyPath: KeyPath<Value, U>) -> U { get }
12+
}
13+
14+
extension Foo {
15+
public var value: Value {
16+
fatalError()
17+
}
18+
}

0 commit comments

Comments
 (0)