mirror of
https://github.com/apple/swift.git
synced 2026-10-10 13:50:43 +02:00
Since reparentable protocols can have less availability than the protocols inheriting from it, we need to first loosen availability checking inheritance clauses to allow for the statement of retroactive refinement. Then, we need to tighten it in other places in terms of expression checking, because we now cannot refer to members of a generic type that originate from an unavailable ancestor of a protocol to which the value conforms. Previously it was not possible for that to be the case, so no checking was performed.
41 lines
782 B
Swift
41 lines
782 B
Swift
#if IncludeNewProto
|
|
@available(macOS 12, *)
|
|
@reparentable public protocol NewProto {
|
|
associatedtype Thing: Equatable
|
|
func new() -> Thing
|
|
}
|
|
|
|
@available(macOS 12, *)
|
|
extension Existing: @reparented NewProto where Thing == String {
|
|
public func new() -> Thing { return "defaulted Existing.new" }
|
|
}
|
|
|
|
public protocol Existing: NewProto {
|
|
associatedtype Thing: Equatable = String
|
|
func existing() -> Thing
|
|
}
|
|
#else
|
|
public protocol Existing {
|
|
associatedtype Thing: Equatable = String
|
|
func existing() -> Thing
|
|
}
|
|
#endif
|
|
|
|
public protocol Derived: Existing {
|
|
func derived() -> Thing
|
|
}
|
|
|
|
|
|
public func libraryFunc(_ s: some Derived) {
|
|
print("libraryFunc start")
|
|
|
|
print(s.derived())
|
|
print(s.existing())
|
|
|
|
#if IncludeNewProto
|
|
print(s.new())
|
|
#endif
|
|
|
|
print("libraryFunc end")
|
|
}
|