forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccessibility_multi.swift
23 lines (20 loc) · 1.13 KB
/
accessibility_multi.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// RUN: %target-swift-frontend -parse -primary-file %s %S/Inputs/accessibility_multi_other.swift -verify
func read(value: Int) {}
func reset(inout value: Int) { value = 0 }
func testGlobals() {
read(privateSetGlobal)
privateSetGlobal = 42 // expected-error {{cannot assign to value: 'privateSetGlobal' setter is inaccessible}}
reset(&privateSetGlobal) // expected-error {{cannot pass immutable value as inout argument: 'privateSetGlobal' setter is inaccessible}}
}
func testProperties(instance: Members) {
var instance = instance
read(instance.privateSetProp)
instance.privateSetProp = 42 // expected-error {{cannot assign to property: 'privateSetProp' setter is inaccessible}}
reset(&instance.privateSetProp) // expected-error {{cannot pass immutable value as inout argument: 'privateSetProp' setter is inaccessible}}
}
func testSubscript(instance: Members) {
var instance = instance
read(instance[])
instance[] = 42 // expected-error {{cannot assign through subscript: subscript setter is inaccessible}}
reset(&instance[]) // expected-error {{cannot pass immutable value as inout argument: subscript setter is inaccessible}}
}