Files
swift-mirror/test/Inputs/resilient_protocol.swift
Slava Pestov 4a47190335 AST: Allow @_fixed_layout protocols
A @_fixed_layout protocol exposes its witness table layout to
clients, which prevents re-ordering of requirements or adding
new requiremenst with a default.

When library evolution is enabled, we still emit method
descriptors even for @_fixed_layout protocols; this allows a
previously-resilient protocol to become @_fixed_layout as long
as the published layout matches the resilient layout in all
previously-shipped versions of the library.
2020-07-20 23:53:41 -04:00

46 lines
979 B
Swift

public protocol OtherResilientProtocol {
}
var x: Int = 0
extension OtherResilientProtocol {
public var propertyInExtension: Int {
get { return x }
set { x = newValue }
}
public static var staticPropertyInExtension: Int {
get { return x }
set { x = newValue }
}
}
public protocol ResilientBaseProtocol {
func requirement() -> Int
}
public protocol ResilientDerivedProtocol : ResilientBaseProtocol {}
public protocol ProtocolWithRequirements {
associatedtype T
func first()
func second()
}
public struct Wrapper<T>: OtherResilientProtocol { }
public struct ConcreteWrapper: OtherResilientProtocol { }
public protocol ProtocolWithAssocTypeDefaults {
associatedtype T1 = Self
associatedtype T2: OtherResilientProtocol = Wrapper<T1>
}
public protocol ResilientSelfDefault : ResilientBaseProtocol {
associatedtype AssocType: ResilientBaseProtocol = Self
}
@_fixed_layout public protocol OtherFrozenProtocol {
func protocolMethod()
}