Files
swift-mirror/test/SILGen/accessors_testing.swift
Joe Groff b246edd25a SIL: Private setters need at least hidden visibility for key paths in more cases.
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.
2021-07-20 16:24:36 -07:00

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
}
}