Skip to content

Commit 88a09ea

Browse files
committed
[embedded] Add a test to exercise multi-protocol class-bound existentials
1 parent 23b721f commit 88a09ea

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo -O) | %FileCheck %s
3+
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -wmo -Osize) | %FileCheck %s
4+
5+
// REQUIRES: swift_in_compiler
6+
// REQUIRES: executable_test
7+
// REQUIRES: optimized_stdlib
8+
// REQUIRES: OS=macosx || OS=linux-gnu
9+
10+
protocol ClassBound: AnyObject {
11+
func foo()
12+
}
13+
14+
protocol OtherProtocol: AnyObject {
15+
func bar()
16+
}
17+
18+
class MyClass: ClassBound, OtherProtocol {
19+
func foo() { print("MyClass.foo()") }
20+
func bar() { print("MyClass.bar()") }
21+
}
22+
23+
func test(existential: any ClassBound & OtherProtocol) {
24+
existential.foo()
25+
existential.bar()
26+
}
27+
28+
@main
29+
struct Main {
30+
static func main() {
31+
test(existential: MyClass())
32+
// CHECK: MyClass.foo()
33+
// CHECK: MyClass.bar()
34+
}
35+
}

0 commit comments

Comments
 (0)