mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The runtime that shipped with Swift 5.1 and earlier had a bug that interfered with backward deployment of binaries that dynamically check for protocol conformances on conditionally-available tests. This was fixed in the top-of-tree Swift runtime by https://github.com/apple/swift/pull/29887; however, that doesn't do much good for running binaries on older OSes that don't have that fix. In order for binaries built with a newer Swift compiler to run successfully on older OSes, introduce a compatibility hook that replaces the conformance cache implementation in the original OS runtime with a version based on the current implementation that has the fix for the protocol conformance bug. Fixes rdar://problem/59460603
28 lines
632 B
Swift
28 lines
632 B
Swift
// RUN: %target-resilience-test --backward-deployment
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
import backward_deploy_conformance
|
|
|
|
var BackwardDeployConformanceTest = TestSuite("BackwardDeployConformance")
|
|
|
|
public class UsesNewStruct: CustomStringConvertible {
|
|
public var field: NewStruct<Bool>? = nil
|
|
public let description = "This is my description"
|
|
}
|
|
|
|
public class OtherClass {}
|
|
|
|
@_optimize(none)
|
|
func blackHole<T>(_: T) {}
|
|
|
|
BackwardDeployConformanceTest.test("ConformanceCache") {
|
|
if getVersion() == 1 {
|
|
blackHole(UsesNewStruct())
|
|
}
|
|
|
|
blackHole(OtherClass() as? CustomStringConvertible)
|
|
}
|
|
|
|
runAllTests()
|