Files
swift-mirror/test/Constraints/opened_existentials_feature.swift
Doug Gregor 6075de1b62 Add upcoming feature ImplicitOpenExistentials for SE-0352
To maintain source compatibility, SE-0352 does not open existentials
with "self-conforming" type, such as `any Error` or existentials based
on `@objc` protocols. The proposal specified that this behavior would
change in Swift 6. Implement that behavior change, which can be
enabled prior to Swift 6 with the upcoming feature
`ImplicitOpenExistentials` (as documented in SE-0362).

Fixes #70873 / rdar://120902975.
2024-03-01 11:50:39 -08:00

21 lines
443 B
Swift

// RUN: %target-typecheck-verify-swift -enable-upcoming-feature ImplicitOpenExistentials
// RUN: %target-typecheck-verify-swift -swift-version 6
#if _runtime(_ObjC)
@objc
protocol X {}
func foo<T: X>(_ val: T.Type) {}
func bar(_ val: X.Type) {
// Only succeeds when we're allowed to open an @objc existential.
foo(val)
}
#endif
func takeError<E: Error>(_ error: E) { }
func passError(error: any Error) {
takeError(error) // okay
}