Files
swift-mirror/test/IRGen/always_emit_into_client_opaque_result.swift
2022-09-15 06:20:07 -07:00

43 lines
967 B
Swift

// RUN: %target-swift-frontend -enable-library-evolution -emit-ir %s
// REQUIRES: OS=macosx
// This test used to crash with a duplicate LLVM IR definition.
@available(macOS 11.0, *)
public protocol Proto1 {}
@available(macOS 11.0, *)
public struct Thing {}
@available(macOS 11.0, *)
public struct Thing0: Proto1 {
public init() {}
}
@available(macOS 11.0, *)
@_marker public protocol MarkerProto {}
@available(macOS 11.0, *)
@frozen
@usableFromInline
struct LimitedAvailability: Proto1, MarkerProto {}
@available(macOS 11.0, *)
extension Thing {
@_alwaysEmitIntoClient
public static func doIt(
_ thingy: (any Proto1 & MarkerProto)?
) -> some Proto1 {
if #available(macOS 13.0, *) {
return thingy as! LimitedAvailability
} else {
return Thing0()
}
}
}
@available(macOS 11.0, *)
public func doIt(_ thingy: (any Proto1 & MarkerProto)?) -> some Proto1 {
return Thing.doIt(thingy)
}