mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
My original fix only addressed the issue for when the property was exactly internal, so we would still run into problems with keypaths and `private(set)` when `-enable-testing` is on, or when referring to `public` properties with private setters from the same module. This generalizes the rule, so that the setter entry point for any property with at least internal visibility also has at least internal visibility, even if the setter is semantically less visible. Fixes rdar://78523318.
28 lines
861 B
Swift
28 lines
861 B
Swift
// RUN: %target-swift-emit-silgen -parse-as-library -module-name accessors %s | %FileCheck %s
|
|
// RUN: %target-swift-emit-silgen -parse-as-library -enable-testing -module-name accessors %s | %FileCheck %s
|
|
|
|
// rdar://78523318: Ensure that private(set) accessors for internal or more
|
|
// visible properties have hidden linkage, because other code inside the module
|
|
// needs to reference the setter to form a key path.
|
|
|
|
public struct Foo {
|
|
// CHECK-LABEL: sil hidden [ossa] @$s9accessors3FooV6internSivs
|
|
private(set) internal var intern: Int {
|
|
get { return 0 }
|
|
set {}
|
|
}
|
|
// CHECK-LABEL: sil hidden [ossa] @$s9accessors3FooV3pubSivs
|
|
private(set) public var pub: Int {
|
|
get { return 0 }
|
|
set {}
|
|
}
|
|
|
|
public mutating func exercise() {
|
|
_ = intern
|
|
_ = pub
|
|
intern = 0
|
|
pub = 0
|
|
}
|
|
}
|
|
|