File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -2392,6 +2392,9 @@ namespace {
2392
2392
// field type.
2393
2393
synthesizer.makeUnionFieldAccessors (result, member);
2394
2394
2395
+ // Union accessors are always unsafe.
2396
+ member->getAttrs ().add (new (Impl.SwiftContext ) UnsafeAttr (/* Implicit=*/ true ));
2397
+
2395
2398
// Create labeled initializers for unions that take one of the
2396
2399
// fields, which only initializes the data for that field.
2397
2400
auto valueCtor =
Original file line number Diff line number Diff line change @@ -19,4 +19,9 @@ struct StoreAllTheThings {
19
19
let ln : ListNode // expected-note{{property 'ln' involves unsafe type 'ListNode'}}
20
20
21
21
let sc : SomeColor
22
- } ;
22
+ }
23
+
24
+ func readFromUnion( npu: NoPointersUnion ) {
25
+ // expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}
26
+ _ = npu. x // expected-note{{reference to unsafe property 'x'}}
27
+ }
You can’t perform that action at this time.
0 commit comments