You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
d(self._usesProjectedValue) // expected-error {{cannot convert value '_usesProjectedValue' of type 'Baz<W>' to expected type 'W', use wrapped value instead}}{{12-13=}}
1069
1069
}
1070
1070
}
1071
+
1072
+
// SR-11393
1073
+
protocolCopyable:AnyObject{
1074
+
func copy()->Self
1075
+
}
1076
+
1077
+
@propertyWrapper
1078
+
structCopyOnWrite<Value:Copyable>{
1079
+
init(wrappedValue:Value){
1080
+
self.wrappedValue = wrappedValue
1081
+
}
1082
+
1083
+
varwrappedValue:Value
1084
+
1085
+
varprojectedValue:Value{
1086
+
mutating get{
1087
+
if !isKnownUniquelyReferenced(&wrappedValue){
1088
+
wrappedValue = wrappedValue.copy()
1089
+
}
1090
+
return wrappedValue
1091
+
}
1092
+
set{
1093
+
wrappedValue = newValue
1094
+
}
1095
+
}
1096
+
}
1097
+
1098
+
finalclassCopyOnWriteTest:Copyable{
1099
+
leta:Int
1100
+
init(a:Int){
1101
+
self.a = a
1102
+
}
1103
+
1104
+
func copy()->Self{
1105
+
Self.init(a: a)
1106
+
}
1107
+
}
1108
+
1109
+
structCopyOnWriteDemo1{
1110
+
@CopyOnWritevara=CopyOnWriteTest(a:3)
1111
+
1112
+
func foo(){ // expected-note{{mark method 'mutating' to make 'self' mutable}}
1113
+
_ = $a // expected-error{{cannot use mutating getter on immutable value: 'self' is immutable}}
1114
+
}
1115
+
}
1116
+
1117
+
@propertyWrapper
1118
+
structNonMutatingProjectedValueSetWrapper<Value>{
1119
+
varwrappedValue:Value
1120
+
varprojectedValue:Value{
1121
+
get{ wrappedValue }
1122
+
nonmutating set{}
1123
+
}
1124
+
}
1125
+
1126
+
structUseNonMutatingProjectedValueSet{
1127
+
@NonMutatingProjectedValueSetWrappervarx=17
1128
+
1129
+
func test(){ // expected-note{{mark method 'mutating' to make 'self' mutable}}
1130
+
$x =42 // okay
1131
+
x =42 // expected-error{{cannot assign to property: 'self' is immutable}}
0 commit comments