mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Type checker] Fix a crash triggered from index-while-building.
This commit is contained in:
@@ -4783,7 +4783,8 @@ performMemberLookup(ConstraintKind constraintKind, DeclName memberName,
|
||||
// as representing "dynamic lookup" unless it's a direct call
|
||||
// to such subscript (in that case label is expected to match).
|
||||
if (auto *subscript = dyn_cast<SubscriptDecl>(cand)) {
|
||||
if (::hasDynamicMemberLookupAttribute(instanceTy,
|
||||
if (memberLocator &&
|
||||
::hasDynamicMemberLookupAttribute(instanceTy,
|
||||
DynamicMemberLookupCache) &&
|
||||
isValidKeyPathDynamicMemberLookup(subscript, TC)) {
|
||||
auto info = getArgumentInfo(memberLocator);
|
||||
|
||||
24
test/Index/Store/dynamic-member-lookup-crash.swift
Normal file
24
test/Index/Store/dynamic-member-lookup-crash.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
// Ensure that we don't crash looking for default implementations during
|
||||
// indexing.
|
||||
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s -verify
|
||||
|
||||
@dynamicMemberLookup
|
||||
protocol B {
|
||||
associatedtype Value
|
||||
|
||||
var value: Value { get }
|
||||
|
||||
subscript<Subject>(dynamicMember dynamicMember: WritableKeyPath<Value, Subject>) -> Value { get }
|
||||
}
|
||||
|
||||
extension B {
|
||||
subscript<Subject>(dynamicMember dynamicMember: WritableKeyPath<Value, Subject>) -> Value {
|
||||
get { value }
|
||||
}
|
||||
}
|
||||
|
||||
struct Foo<Value>: B {
|
||||
var value: Value
|
||||
}
|
||||
Reference in New Issue
Block a user