mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
aad51cab01
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.
35 lines
745 B
Swift
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
|
|
}
|
|
}
|