mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
31 lines
583 B
Swift
31 lines
583 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -g %s -o %t/bin
|
|
// RUN: %target-codesign %t/bin
|
|
// RUN: %target-run %t/bin | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
protocol Boopable: ~Copyable {
|
|
func boop()
|
|
mutating func bonk()
|
|
}
|
|
|
|
struct S: ~Copyable, Boopable {
|
|
func boop() { print("boop") }
|
|
mutating func bonk() { print("hmm") }
|
|
}
|
|
|
|
func borrow(_ b: borrowing any Boopable & ~Copyable) {
|
|
b.boop()
|
|
}
|
|
|
|
func mutate(_ b: inout any Boopable & ~Copyable) {
|
|
b.bonk()
|
|
}
|
|
|
|
// CHECK: boop
|
|
// CHECK: hmm
|
|
borrow(S())
|
|
var s = S() as any Boopable & ~Copyable
|
|
mutate(&s)
|