File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -124,3 +124,32 @@ struct WrapperContext {
124
124
static let propUsingMember = originalValue
125
125
}
126
126
}
127
+
128
+ // Class-constrained extension where protocol does not impose class requirement
129
+
130
+ protocol DoesNotImposeClassReq_1 { }
131
+
132
+ class JustAClass : DoesNotImposeClassReq_1 {
133
+ var property : String = " "
134
+ }
135
+
136
+ extension DoesNotImposeClassReq_1 where Self: JustAClass {
137
+ var wrappingProperty : String {
138
+ get { return property }
139
+ set { property = newValue }
140
+ }
141
+ }
142
+
143
+ let instanceOfJustAClass = JustAClass ( ) // expected-note {{change 'let' to 'var' to make it mutable}}
144
+ instanceOfJustAClass. wrappingProperty = " " // expected-error {{cannot assign to property: 'instanceOfJustAClass' is a 'let' constant}}
145
+
146
+ protocol DoesNotImposeClassReq_2 {
147
+ var property : String { get set }
148
+ }
149
+
150
+ extension DoesNotImposeClassReq_2 where Self : AnyObject {
151
+ var wrappingProperty : String {
152
+ get { property }
153
+ set { property = newValue } // Okay
154
+ }
155
+ }
You can’t perform that action at this time.
0 commit comments