mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
24 lines
1.1 KiB
Swift
24 lines
1.1 KiB
Swift
// RUN: %target-swift-frontend -parse -primary-file %s %S/Inputs/accessibility_multi_other.swift -verify
|
|
func read(value: Int) {}
|
|
func reset(value: inout 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}}
|
|
}
|