Skip to content

Commit 528558d

Browse files
committed
[Test] Adds another test case
1 parent 77e1626 commit 528558d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/decl/ext/extensions.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,30 @@ extension DoesNotImposeClassReq_2 where Self : AnyObject {
227227
}
228228
}
229229

230+
protocol DoesNotImposeClassReq_3 {
231+
var someProperty: Int { get set }
232+
}
233+
234+
class JustAClass1: DoesNotImposeClassReq_3 {
235+
var someProperty = 0
236+
}
237+
238+
extension DoesNotImposeClassReq_3 where Self: JustAClass1 {
239+
var anotherProperty1: Int {
240+
get { return someProperty }
241+
set { someProperty = newValue } // Okay
242+
}
243+
244+
var anotherProperty2: Int {
245+
get { return someProperty }
246+
set { someProperty = newValue } // Okay
247+
}
248+
}
249+
250+
let justAClass1 = JustAClass1() // expected-note {{change 'let' to 'var' to make it mutable}}
251+
justAClass1.anotherProperty1 = 1234 // Okay
252+
justAClass1.anotherProperty2 = 4321 // expected-error {{cannot assign to property: 'justAClass1' is a 'let' constant}}
253+
230254
// Reject extension of nominal type via parameterized typealias
231255

232256
struct Nest<Egg> { typealias Contents = Egg }

0 commit comments

Comments
 (0)