Files
swift-mirror/test/Interop/Cxx/foreign-reference/print-reference.swift
Egor Zhdan a292113ef2 [cxx-interop] Fix test failure on older macOS
The runtime logic for printing a foreign reference type is behind `if #available(SwiftStdlib 6.2, *)`, which means it won't run on older versions of macOS, even if you use a newer Swift runtime.

rdar://153735437
2025-06-24 13:36:22 +01:00

56 lines
1.3 KiB
Swift

// RUN: %target-run-simple-swift(-cxx-interoperability-mode=default -I %S/Inputs) | %FileCheck %s
// REQUIRES: executable_test
// Metadata for foreign reference types is not supported on Windows.
// UNSUPPORTED: OS=windows-msvc
// Temporarily disable when running with an older runtime (rdar://153205860)
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: back_deployment_runtime
import Printed
func printCxxImmortalFRT() {
if #available(SwiftStdlib 6.2, *) {
let s = ImmortalFRT()
print(s)
} else {
print("runtime too old")
}
}
@available(SwiftStdlib 5.9, *)
extension FRTCustomStringConvertible : CustomStringConvertible {
public var description: String {
return "FRTCustomStringConvertible(publ: \(publ))"
}
}
func printCxxFRTCustomStringConvertible() {
if #available(SwiftStdlib 5.9, *) {
let s = FRTCustomStringConvertible()
print(s)
} else {
print("runtime too old")
}
}
func printCxxFRType() {
if #available(SwiftStdlib 6.2, *) {
let s = FRType()
print(s)
} else {
print("runtime too old")
}
}
printCxxImmortalFRT()
// CHECK: {{ImmortalFRT()|runtime too old}}
printCxxFRTCustomStringConvertible()
// CHECK: FRTCustomStringConvertible(publ: 2)
printCxxFRType()
// CHECK: {{FRType()|runtime too old}}