Skip to content

Commit 780c4e9

Browse files
committed
Sema: Fix isValidKeyPathDynamicMemberLookup() for noncopyable generics
1 parent 7204a69 commit 780c4e9

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,9 +1848,18 @@ bool swift::isValidKeyPathDynamicMemberLookup(SubscriptDecl *decl,
18481848
auto layout = existential->getExistentialLayout();
18491849

18501850
auto protocols = layout.getProtocols();
1851-
if (!(protocols.size() == 1 &&
1852-
protocols[0] == ctx.getProtocol(KnownProtocolKind::Sendable)))
1851+
if (!llvm::all_of(protocols,
1852+
[&](ProtocolDecl *proto) {
1853+
if (proto->isSpecificProtocol(KnownProtocolKind::Sendable))
1854+
return true;
1855+
1856+
if (proto->getInvertibleProtocolKind())
1857+
return true;
1858+
1859+
return false;
1860+
})) {
18531861
return false;
1862+
}
18541863

18551864
paramTy = layout.getSuperclass();
18561865
if (!paramTy)

test/Concurrency/sendable_keypaths.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -enable-upcoming-feature InferSendableFromCaptures -strict-concurrency=complete
22

3-
// XFAIL: noncopyable_generics
4-
53
// REQUIRES: concurrency
64
// REQUIRES: asserts
75

test/Interpreter/keypath.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-run-simple-swift | %FileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
// REQUIRES: executable_test
64

75
// UNSUPPORTED: use_os_stdlib

test/attr/attr_dynamic_member_lookup.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-typecheck-verify-swift
22

3-
// XFAIL: noncopyable_generics
4-
53
var global = 42
64

75
@dynamicMemberLookup

0 commit comments

Comments
 (0)