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 {
23922392 // field type.
23932393 synthesizer.makeUnionFieldAccessors (result, member);
23942394
2395+ // Union accessors are always unsafe.
2396+ member->getAttrs ().add (new (Impl.SwiftContext ) UnsafeAttr (/* Implicit=*/ true ));
2397+
23952398 // Create labeled initializers for unions that take one of the
23962399 // fields, which only initializes the data for that field.
23972400 auto valueCtor =
Original file line number Diff line number Diff line change @@ -19,4 +19,9 @@ struct StoreAllTheThings {
1919 let ln : ListNode // expected-note{{property 'ln' involves unsafe type 'ListNode'}}
2020
2121 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