Files
swift-mirror/test/embedded/existential-class-bound5.swift
T
Doug Gregor aad51cab01 [Embedded] Remove the ability to disable existentials in Embedded Swift
Support for existentials in Embedded Swift has been available for a
little while now and appears to be solid. Remove the ability to disable
them (via `-disable-experimental-feature EmbeddedExistentials`), both
because it simplifies the code and because it's an ABI break to
disable the feature.
2026-04-17 17:38:01 -07:00

35 lines
745 B
Swift

// RUN: %target-swift-emit-ir -parse-as-library -module-name main -verify %s -enable-experimental-feature Embedded -wmo
// REQUIRES: swift_in_compiler
// REQUIRES: optimized_stdlib
// REQUIRES: swift_feature_Embedded
protocol ClassBound: AnyObject {
func foo()
}
protocol NotClassBound {
func foo()
}
class MyClass {}
extension MyClass: ClassBound, NotClassBound {
func foo() { print("MyClass.foo()") }
}
func test(existential: any ClassBound) {
existential.foo() // ok
}
func test(existential: any NotClassBound) {
existential.foo()
}
@main
struct Main {
static func main() {
test(existential: MyClass() as (any ClassBound)) // ok
test(existential: MyClass() as (any NotClassBound)) // ok
}
}