Files
swift-mirror/test/embedded/existential-composition.swift
Arnold Schwaighofer d019f37b68 [embedded] Enable support for existentials/boxed protocol types per default
And enable this feature in production.
2025-12-10 08:50:23 -08:00

28 lines
678 B
Swift

// RUN: %target-swift-emit-ir -parse-as-library -module-name main -verify %s -enable-experimental-feature Embedded -wmo -disable-embedded-existentials
// REQUIRES: swift_feature_Embedded
protocol ClassBound: AnyObject {
func foo()
}
protocol OtherProtocol {
func bar()
}
class MyClass: ClassBound, OtherProtocol {
func foo() { print("MyClass.foo()") }
func bar() { print("MyClass.bar()") }
}
// Currently we don't support this
func test(existential: any ClassBound & OtherProtocol) {
}
@main
struct Main {
static func main() {
test(existential: MyClass()) // expected-error {{cannot use a value of protocol type 'any OtherProtocol' in embedded Swift}}
}
}