Files
swift-mirror/test/Runtime/protocol_conformance_collision.swift
Artem Chikin 1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00

82 lines
2.1 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/newSDK %target-link-sdk-2021-version
// RUN: %target-codesign %t/newSDK
// RUN: %target-run %t/newSDK newSDK
// RUN: %target-build-swift %s -o %t/oldSDK %target-link-sdk-2020-version
// RUN: %target-codesign %t/oldSDK
// RUN: %target-run %t/oldSDK oldSDK
// REQUIRES: VENDOR=apple
// REQUIRES: executable_test
// Simulators refuse to run binaries built with an SDK newer than the simulator.
// UNSUPPORTED: DARWIN_SIMULATOR=ios
// UNSUPPORTED: DARWIN_SIMULATOR=tvos
// UNSUPPORTED: DARWIN_SIMULATOR=watchos
// UNSUPPORTED: DARWIN_SIMULATOR=xros
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
import Accelerate
import Foundation
import StdlibUnittest
import SwiftShims
extension CFString: Hashable {
static var localHashableCallCount = 0
public var hashValue: Int {
Self.localHashableCallCount += 1
return (self as String).hashValue
}
}
protocol P {
func firstHashValue() -> Int
}
extension Set: P {
func firstHashValue() -> Int {
return first!.hashValue
}
}
@_optimize(none)
func firstHashValue(_ x: P) -> Int {
x.firstHashValue()
}
let osHasWorkaround: Bool
// These are deliberately not the standard 9999, as we don't want to hit the
// special case where it's always available, and we don't want this check to be
// rewritten in any find/replace operations.
if #available(macOS 9998, iOS 9998, tvOS 9998, watchOS 9998, *) {
osHasWorkaround = true
} else {
osHasWorkaround = false
}
let testingOldSDK = CommandLine.arguments.last == "oldSDK"
var tests: TestSuite
if testingOldSDK {
tests = TestSuite("old SDK protocol conformance collision")
tests.test("CFString: Hashable conformance") {
_ = firstHashValue(NSSet(object: "Whatever") as! Set<CFString>)
let expectedCallCount = osHasWorkaround ? 1 : 0
expectEqual(expectedCallCount, CFString.localHashableCallCount)
}
} else {
tests = TestSuite("new SDK protocol conformance collision")
tests.test("CFString: Hashable conformance") {
_ = firstHashValue(NSSet(object: "Whatever") as! Set<CFString>)
expectEqual(0, CFString.localHashableCallCount)
}
}
runAllTests()