Skip to content

Commit d3461e1

Browse files
authored
Merge pull request #27966 from mikeash/fix-new-error-test-back-deployment
[Test] Don't test _swift_willThrow on older runtimes.
2 parents 6acf8db + a2cf576 commit d3461e1

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

test/stdlib/Error.swift

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,27 @@ ErrorTests.test("test dealloc empty error box") {
193193

194194
var errors: [Error] = []
195195
ErrorTests.test("willThrow") {
196-
// Error isn't allowed in a @convention(c) function when ObjC interop is
197-
// not available, so pass it through an OpaquePointer.
198-
typealias WillThrow = @convention(c) (OpaquePointer) -> Void
199-
let willThrow = pointerToSwiftCoreSymbol(name: "_swift_willThrow")!
200-
let callback: WillThrow = {
201-
errors.append(unsafeBitCast($0, to: Error.self))
202-
}
203-
willThrow.storeBytes(of: callback, as: WillThrow.self)
204-
expectTrue(errors.isEmpty)
205-
do {
206-
throw UnsignedError.negativeOne
207-
} catch {}
208-
expectEqual(UnsignedError.self, type(of: errors.last!))
196+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
197+
// Error isn't allowed in a @convention(c) function when ObjC interop is
198+
// not available, so pass it through an OpaquePointer.
199+
typealias WillThrow = @convention(c) (OpaquePointer) -> Void
200+
let willThrow = pointerToSwiftCoreSymbol(name: "_swift_willThrow")!
201+
let callback: WillThrow = {
202+
errors.append(unsafeBitCast($0, to: Error.self))
203+
}
204+
willThrow.storeBytes(of: callback, as: WillThrow.self)
205+
expectTrue(errors.isEmpty)
206+
do {
207+
throw UnsignedError.negativeOne
208+
} catch {}
209+
expectEqual(UnsignedError.self, type(of: errors.last!))
209210

210-
do {
211-
throw SillyError.JazzHands
212-
} catch {}
213-
expectEqual(2, errors.count)
214-
expectEqual(SillyError.self, type(of: errors.last!))
211+
do {
212+
throw SillyError.JazzHands
213+
} catch {}
214+
expectEqual(2, errors.count)
215+
expectEqual(SillyError.self, type(of: errors.last!))
216+
}
215217
}
216218

217219
runAllTests()

0 commit comments

Comments
 (0)