mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We now may have constrained existentials that have no primary associated types, so there won't be any arguments for the parameterized protocol type. Because the "constrained" part is that there's an inverse. resolves rdar://128695929
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)
|