Skip to content

Commit 3382352

Browse files
committed
[send-non-sendable] Make sure that we translate project_box into the pseudo-IR.
This is a case of an instruction that we missed translating into the pseudo-IR. This was easy to do since we are not yet performing an exhaustive switch over all instruction kinds when translating. Earlier I did the first part of the translation by switching from doing conditional is<INST> to switch but haven't yet eliminated the default yet from the switch. I am fixing this now since with my load [copy] change from earlier causes us to crash in the earlier unorganized tests. rdar://115367810
1 parent 3a377a3 commit 3382352

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/SILOptimizer/Mandatory/SendNonSendable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ class PartitionOpTranslator {
770770
case SILInstructionKind::PointerToAddressInst:
771771
case SILInstructionKind::ProjectBlockStorageInst:
772772
case SILInstructionKind::RefElementAddrInst:
773+
case SILInstructionKind::ProjectBoxInst:
773774
case SILInstructionKind::RefToUnmanagedInst:
774775
case SILInstructionKind::StrongCopyUnownedValueInst:
775776
case SILInstructionKind::StructElementAddrInst:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-swift-frontend -emit-sil -strict-concurrency=complete -enable-experimental-feature SendNonSendable -disable-availability-checking -verify %s -o /dev/null
2+
3+
// REQUIRES: concurrency
4+
// REQUIRES: asserts
5+
6+
////////////////////////
7+
// MARK: Declarations //
8+
////////////////////////
9+
10+
/// Classes are always non-sendable, so this is non-sendable
11+
class NonSendableKlass {
12+
func asyncCall() async {}
13+
}
14+
15+
actor Actor {
16+
var klass = NonSendableKlass()
17+
final var finalKlass = NonSendableKlass()
18+
}
19+
20+
final actor FinalActor {
21+
var klass = NonSendableKlass()
22+
}
23+
24+
/////////////////////////////
25+
// MARK: Closure Formation //
26+
/////////////////////////////
27+
28+
// This test makes sure that we can properly pattern match project_box.
29+
func formClosureWithoutCrashing() {
30+
var c = NonSendableKlass() // expected-warning {{variable 'c' was never mutated; consider changing to 'let' constant}}
31+
let _ = { print(c) }
32+
}

0 commit comments

Comments
 (0)