mirror of
https://github.com/apple/swift.git
synced 2026-10-12 14:50:47 +02:00
An existential that mixes an @objc protocol with a Swift protocol that carries a witness table is class-constrained, since an @objc protocol can only be adopted by classes. Assisted-by: claude rdar://177199463
33 lines
856 B
Swift
33 lines
856 B
Swift
import Foundation
|
|
|
|
@objc public protocol ObjCProto {}
|
|
|
|
public protocol ClassConstrainedProto: AnyObject {
|
|
var payload: Int { get }
|
|
}
|
|
|
|
public protocol UnconstrainedProto {
|
|
var payload: Int { get }
|
|
}
|
|
|
|
public struct MixedWithClassConstrainedProto {
|
|
public var existential: ObjCProto & ClassConstrainedProto
|
|
public init(existential: ObjCProto & ClassConstrainedProto) {
|
|
self.existential = existential
|
|
}
|
|
}
|
|
|
|
public struct MixedWithUnconstrainedProto {
|
|
public var existential: ObjCProto & UnconstrainedProto
|
|
public init(existential: ObjCProto & UnconstrainedProto) {
|
|
self.existential = existential
|
|
}
|
|
}
|
|
|
|
public struct MixedExistentialMetatype {
|
|
public var metatype: (ObjCProto & UnconstrainedProto).Type
|
|
public init(metatype: (ObjCProto & UnconstrainedProto).Type) {
|
|
self.metatype = metatype
|
|
}
|
|
}
|