@@ -19,11 +19,8 @@ func _recordIssue(
19
19
#if os(WASI)
20
20
let _recordIssue = _recordIssue ( )
21
21
#else
22
- guard let pointer = pointer ( for: " IssueReportingTestSupport_RecordIssue " )
22
+ guard let _recordIssue = function ( for: " IssueReportingTestSupport_RecordIssue " )
23
23
else { return }
24
- let _recordIssue = withUnsafePointer ( to: pointer) {
25
- UnsafeRawPointer ( $0) . assumingMemoryBound ( to: DynamicFunction . self) . pointee ( )
26
- }
27
24
#endif
28
25
let recordIssue = _recordIssue as! ( String ? , String , String , Int , Int ) -> Void
29
26
recordIssue ( message, fileID, filePath, line, column)
@@ -38,11 +35,8 @@ func _withKnownIssue(
38
35
#if os(WASI)
39
36
let _withKnownIssue = _withKnownIssue ( )
40
37
#else
41
- guard let pointer = pointer ( for: " IssueReportingTestSupport_WithKnownIssue " )
38
+ guard let _withKnownIssue = function ( for: " IssueReportingTestSupport_WithKnownIssue " )
42
39
else { return }
43
- let _withKnownIssue = withUnsafePointer ( to: pointer) {
44
- UnsafeRawPointer ( $0) . assumingMemoryBound ( to: DynamicFunction . self) . pointee ( )
45
- }
46
40
#endif
47
41
let withKnownIssue = _withKnownIssue as! ( String ? , Bool , ( ) throws -> Void ) -> Void
48
42
withKnownIssue ( message, isIntermittent, body)
@@ -54,11 +48,8 @@ func _currentTestIsNotNil() -> Bool {
54
48
#if os(WASI)
55
49
let _currentTestIsNotNil = _currentTestIsNotNil ( )
56
50
#else
57
- guard let pointer = pointer ( for: " IssueReportingTestSupport_CurrentTestIsNotNil " )
51
+ guard let _currentTestIsNotNil = function ( for: " IssueReportingTestSupport_CurrentTestIsNotNil " )
58
52
else { return false }
59
- let _currentTestIsNotNil = withUnsafePointer ( to: pointer) {
60
- UnsafeRawPointer ( $0) . assumingMemoryBound ( to: DynamicFunction . self) . pointee ( )
61
- }
62
53
#endif
63
54
let currentTestIsNotNil = _currentTestIsNotNil as! ( ) -> Bool
64
55
return currentTestIsNotNil ( )
@@ -69,11 +60,8 @@ func _XCTFail(_ message: String, file: StaticString, line: UInt) {
69
60
#if os(WASI)
70
61
let _XCTFail = _XCTFail ( )
71
62
#else
72
- guard let pointer = pointer ( for: " IssueReportingTestSupport_XCTFail " )
63
+ guard let _XCTFail = function ( for: " IssueReportingTestSupport_XCTFail " )
73
64
else { return }
74
- let _XCTFail = withUnsafePointer ( to: pointer) {
75
- UnsafeRawPointer ( $0) . assumingMemoryBound ( to: DynamicFunction . self) . pointee ( )
76
- }
77
65
#endif
78
66
let XCTFail = _XCTFail as! ( String , StaticString , UInt ) -> Void
79
67
XCTFail ( message, file, line)
@@ -88,11 +76,8 @@ func _XCTExpectFailure(
88
76
#if os(WASI)
89
77
let _XCTExpectFailure = _XCTExpectFailure ( )
90
78
#else
91
- guard let pointer = pointer ( for: " IssueReportingTestSupport_XCTExpectFailure " )
79
+ guard let _XCTExpectFailure = function ( for: " IssueReportingTestSupport_XCTExpectFailure " )
92
80
else { return }
93
- let _XCTExpectFailure = withUnsafePointer ( to: pointer) {
94
- UnsafeRawPointer ( $0) . assumingMemoryBound ( to: DynamicFunction . self) . pointee ( )
95
- }
96
81
#endif
97
82
let XCTExpectFailure = _XCTExpectFailure as! ( String ? , Bool ? , ( ) throws -> Void ) throws -> Void
98
83
try Result { try XCTExpectFailure ( failureReason, strict, failingBlock) } . _rethrowGet ( )
@@ -105,21 +90,21 @@ func _XCTExpectFailure(
105
90
private typealias DynamicFunction = @convention ( c) ( ) -> Any
106
91
#endif
107
92
108
- private func pointer ( for symbol: String ) -> UnsafeMutableRawPointer ? {
93
+ private func function ( for symbol: String ) -> Any ? {
109
94
#if os(Linux)
110
95
let symbol = symbolMap [ symbol] ?? symbol
111
96
guard
112
97
let handle = dlopen ( " libIssueReportingTestSupport.so " , RTLD_LAZY) ,
113
98
let pointer = dlsym ( handle, symbol)
114
99
else { return nil }
115
- return pointer
100
+ return unsafeBitCast ( pointer, to : DynamicFunction . self ) ( )
116
101
#elseif os(Windows)
117
102
let symbol = symbolMap [ symbol]
118
103
guard
119
104
let handle = LoadLibraryA ( " IssueReportingTestSupport.dll " ) ,
120
105
let pointer = GetProcAddress ( handle, symbol)
121
106
else { return nil }
122
- return pointer
107
+ return unsafeBitCast ( pointer, to : DynamicFunction . self ) ( )
123
108
#else
124
109
guard
125
110
let prefix,
@@ -128,7 +113,7 @@ func _XCTExpectFailure(
128
113
let handle = dlopen ( path, RTLD_LAZY) ,
129
114
let pointer = dlsym ( handle, symbol)
130
115
else { return nil }
131
- return pointer
116
+ return unsafeBitCast ( pointer, to : DynamicFunction . self ) ( )
132
117
#endif
133
118
}
134
119
0 commit comments