Skip to content

Commit 7882a97

Browse files
authored
Merge pull request swiftlang#27127 from DougGregor/dynamic-member-lookup-iwb-crash
[Type checker] Fix a crash triggered from index-while-building.
2 parents f044911 + 7151d0e commit 7882a97

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4713,7 +4713,8 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
47134713
// as representing "dynamic lookup" unless it's a direct call
47144714
// to such subscript (in that case label is expected to match).
47154715
if (auto *subscript = dyn_cast<SubscriptDecl>(cand)) {
4716-
if (::hasDynamicMemberLookupAttribute(instanceTy,
4716+
if (memberLocator &&
4717+
::hasDynamicMemberLookupAttribute(instanceTy,
47174718
DynamicMemberLookupCache) &&
47184719
isValidKeyPathDynamicMemberLookup(subscript, TC)) {
47194720
auto info = getArgumentInfo(memberLocator);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Ensure that we don't crash looking for default implementations during
2+
// indexing.
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s -verify
6+
7+
@dynamicMemberLookup
8+
protocol B {
9+
associatedtype Value
10+
11+
var value: Value { get }
12+
13+
subscript<Subject>(dynamicMember dynamicMember: WritableKeyPath<Value, Subject>) -> Value { get }
14+
}
15+
16+
extension B {
17+
subscript<Subject>(dynamicMember dynamicMember: WritableKeyPath<Value, Subject>) -> Value {
18+
get { value }
19+
}
20+
}
21+
22+
struct Foo<Value>: B {
23+
var value: Value
24+
}

0 commit comments

Comments
 (0)