File tree Expand file tree Collapse file tree 4 files changed +31
-8
lines changed Expand file tree Collapse file tree 4 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -1781,18 +1781,18 @@ bool AbstractStorageDecl::isFormallyResilient() const {
1781
1781
if (getAttrs ().hasAttribute <FixedLayoutAttr>())
1782
1782
return false ;
1783
1783
1784
- // Private and (unversioned) internal variables always have a
1785
- // fixed layout.
1786
- if (!getFormalAccessScope (/* useDC=*/ nullptr ,
1787
- /* treatUsableFromInlineAsPublic=*/ true ).isPublic ())
1788
- return false ;
1789
-
1790
1784
// If we're an instance property of a nominal type, query the type.
1791
1785
auto *dc = getDeclContext ();
1792
1786
if (!isStatic ())
1793
1787
if (auto *nominalDecl = dc->getSelfNominalTypeDecl ())
1794
1788
return nominalDecl->isResilient ();
1795
1789
1790
+ // Non-public global and static variables always have a
1791
+ // fixed layout.
1792
+ if (!getFormalAccessScope (/* useDC=*/ nullptr ,
1793
+ /* treatUsableFromInlineAsPublic=*/ true ).isPublic ())
1794
+ return false ;
1795
+
1796
1796
return true ;
1797
1797
}
1798
1798
Original file line number Diff line number Diff line change @@ -91,3 +91,7 @@ public struct ResilientWeakRef {
91
91
public struct ResilientRef {
92
92
public var r : Referent
93
93
}
94
+
95
+ public struct ResilientWithInternalField {
96
+ var x : Int
97
+ }
Original file line number Diff line number Diff line change 1
1
2
2
// RUN: %empty-directory(%t)
3
- // RUN: %target-swift-frontend -module-name struct_resilience - emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
4
- // RUN: %target-swift-emit-silgen -module-name struct_resilience - I %t -enable-sil-ownership -enable-resilience %s | %FileCheck %s
3
+ // RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership %S/../Inputs/resilient_struct.swift
4
+ // RUN: %target-swift-emit-silgen -I %t -enable-sil-ownership -enable-resilience %s | %FileCheck %s
5
5
6
6
import resilient_struct
7
7
Original file line number Diff line number Diff line change
1
+
2
+ // RUN: %empty-directory(%t)
3
+ // RUN: %target-swift-frontend -emit-module -enable-resilience -enable-testing -emit-module-path=%t/resilient_struct.swiftmodule -enable-sil-ownership %S/../Inputs/resilient_struct.swift
4
+ // RUN: %target-swift-emit-silgen -I %t -enable-sil-ownership %s | %FileCheck %s
5
+
6
+ @testable import resilient_struct
7
+
8
+ // CHECK-LABEL: sil @$s26struct_resilience_testable37takesResilientStructWithInternalFieldySi010resilient_A00eghI0VF : $@convention(thin) (@in_guaranteed ResilientWithInternalField) -> Int
9
+ // CHECK: [[COPY:%.*]] = alloc_stack $ResilientWithInternalField
10
+ // CHECK: copy_addr %0 to [initialization] [[COPY]] : $*ResilientWithInternalField
11
+ // CHECK: [[FN:%.*]] = function_ref @$s16resilient_struct26ResilientWithInternalFieldV1xSivg : $@convention(method) (@in_guaranteed ResilientWithInternalField) -> Int
12
+ // CHECK: [[RESULT:%.*]] = apply [[FN]]([[COPY]])
13
+ // CHECK: destroy_addr [[COPY]]
14
+ // CHECK: dealloc_stack [[COPY]]
15
+ // CHECK: return [[RESULT]]
16
+
17
+ public func takesResilientStructWithInternalField( _ s: ResilientWithInternalField ) -> Int {
18
+ return s. x
19
+ }
You can’t perform that action at this time.
0 commit comments