File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -367,12 +367,12 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
367
367
auto effectiveAccess = d->getEffectiveAccess ();
368
368
369
369
// Private setter implementations for an internal storage declaration should
370
- // be internal as well, so that a dynamically-writable
371
- // keypath can be formed from other files.
370
+ // be at least internal as well, so that a dynamically-writable
371
+ // keypath can be formed from other files in the same module .
372
372
if (auto accessor = dyn_cast<AccessorDecl>(d)) {
373
373
if (accessor->isSetter ()
374
- && accessor->getStorage ()->getEffectiveAccess () = = AccessLevel::Internal)
375
- effectiveAccess = AccessLevel::Internal;
374
+ && accessor->getStorage ()->getEffectiveAccess () > = AccessLevel::Internal)
375
+ effectiveAccess = std::max (effectiveAccess, AccessLevel::Internal) ;
376
376
}
377
377
378
378
switch (effectiveAccess) {
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-emit-silgen -parse-as-library -module-name accessors %s | %FileCheck %s
2
+ // RUN: %target-swift-emit-silgen -parse-as-library -enable-testing -module-name accessors %s | %FileCheck %s
3
+
4
+ // rdar://78523318: Ensure that private(set) accessors for internal or more
5
+ // visible properties have hidden linkage, because other code inside the module
6
+ // needs to reference the setter to form a key path.
7
+
8
+ public struct Foo {
9
+ // CHECK-LABEL: sil hidden [ossa] @$s9accessors3FooV6internSivs
10
+ private( set) internal var intern : Int {
11
+ get { return 0 }
12
+ set { }
13
+ }
14
+ // CHECK-LABEL: sil hidden [ossa] @$s9accessors3FooV3pubSivs
15
+ private( set) public var pub : Int {
16
+ get { return 0 }
17
+ set { }
18
+ }
19
+
20
+ public mutating func exercise( ) {
21
+ _ = intern
22
+ _ = pub
23
+ intern = 0
24
+ pub = 0
25
+ }
26
+ }
27
+
You can’t perform that action at this time.
0 commit comments