File tree Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -1523,9 +1523,15 @@ static VarDecl *synthesizePropertyWrapperStorageWrapperProperty(
1523
1523
addMemberToContextIfNeeded (pbd, dc, var);
1524
1524
pbd->setStatic (var->isStatic ());
1525
1525
1526
- // The property is always private.
1527
- property->overwriteAccess (AccessLevel::Private);
1528
- property->overwriteSetterAccess (AccessLevel::Private);
1526
+ // Determine the access level for the property.
1527
+ AccessLevel access =
1528
+ std::min (AccessLevel::Internal, var->getFormalAccess ());
1529
+ property->overwriteAccess (access);
1530
+
1531
+ // Determine setter access.
1532
+ AccessLevel setterAccess =
1533
+ std::min (AccessLevel::Internal, var->getSetterFormalAccess ());
1534
+ property->overwriteSetterAccess (setterAccess);
1529
1535
1530
1536
// Add the accessors we need.
1531
1537
bool hasSetter = wrapperVar->isSettable (nullptr ) &&
Original file line number Diff line number Diff line change @@ -191,14 +191,10 @@ struct WrapperWithStorageValue<T> {
191
191
192
192
struct UseWrapperWithStorageValue {
193
193
// UseWrapperWithStorageValue.$x.getter
194
- // CHECK-LABEL: sil private [ ossa] @$s17property_wrappers26UseWrapperWithStorageValueV2$x33_{{.*}}SiGvg : $@convention(method) (UseWrapperWithStorageValue) -> Wrapper<Int>
194
+ // CHECK-LABEL: sil hidden [transparent] [ ossa] @$s17property_wrappers26UseWrapperWithStorageValueV2$xAA0D0VySiGvg : $@convention(method) (UseWrapperWithStorageValue) -> Wrapper<Int>
195
195
// CHECK-NOT: return
196
196
// CHECK: function_ref @$s17property_wrappers23WrapperWithStorageValueV07wrapperF0AA0C0VyxGvg
197
197
@WrapperWithStorageValue ( value: 17 ) var x : Int
198
-
199
- func foo( ) {
200
- _ = $x
201
- }
202
198
}
203
199
204
200
@propertyWrapper
Original file line number Diff line number Diff line change @@ -695,7 +695,6 @@ extension Wrapper {
695
695
696
696
struct TestStorageRef {
697
697
@WrapperWithStorageRef var x : Int // expected-note{{'$$x' declared here}}
698
- // expected-note@-1{{'$x' declared here}}
699
698
700
699
init ( x: Int ) {
701
700
self . $$x = WrapperWithStorageRef ( wrappedValue: x)
@@ -713,10 +712,25 @@ struct TestStorageRef {
713
712
}
714
713
715
714
func testStorageRef( tsr: TestStorageRef ) {
716
- let _: Wrapper = tsr. $x // expected-error{{'$x' is inaccessible due to 'private' protection level}}
715
+ let _: Wrapper = tsr. $x
717
716
_ = tsr . $$x // expected-error{{'$$x' is inaccessible due to 'private' protection level}}
718
717
}
719
718
719
+ struct TestStorageRefPrivate {
720
+ @WrapperWithStorageRef private( set) var x : Int
721
+
722
+ init ( ) {
723
+ self . $$x = WrapperWithStorageRef ( wrappedValue: 5 )
724
+ }
725
+ }
726
+
727
+ func testStorageRefPrivate( ) {
728
+ var tsr = TestStorageRefPrivate ( )
729
+ let a = tsr. $x // okay, getter is internal
730
+ tsr. $x = a // expected-error{{cannot assign to property: '$x' is immutable}}
731
+ }
732
+
733
+
720
734
// rdar://problem/50873275 - crash when using wrapper with wrapperValue in
721
735
// generic type.
722
736
@propertyWrapper
You can’t perform that action at this time.
0 commit comments