@@ -34,27 +34,33 @@ public func reportIssue(
3434 line: UInt = #line,
3535 column: UInt = #column
3636) {
37+ let ( fileID, filePath, line, column) = (
38+ IssueContext . current? . fileID ?? fileID,
39+ IssueContext . current? . filePath ?? filePath,
40+ IssueContext . current? . line ?? line,
41+ IssueContext . current? . column ?? column
42+ )
3743 guard let context = TestContext . current else {
3844 guard !isTesting else { return }
3945 if let observer = FailureObserver . current {
4046 observer. withLock { $0 += 1 }
4147 for reporter in IssueReporters . current {
4248 reporter. expectIssue (
4349 message ( ) ,
44- fileID: IssueContext . current ? . fileID ?? fileID,
45- filePath: IssueContext . current ? . filePath ?? filePath,
46- line: IssueContext . current ? . line ?? line,
47- column: IssueContext . current ? . column ?? column
50+ fileID: fileID,
51+ filePath: filePath,
52+ line: line,
53+ column: column
4854 )
4955 }
5056 } else {
5157 for reporter in IssueReporters . current {
5258 reporter. reportIssue (
5359 message ( ) ,
54- fileID: IssueContext . current ? . fileID ?? fileID,
55- filePath: IssueContext . current ? . filePath ?? filePath,
56- line: IssueContext . current ? . line ?? line,
57- column: IssueContext . current ? . column ?? column
60+ fileID: fileID,
61+ filePath: filePath,
62+ line: line,
63+ column: column
5864 )
5965 }
6066 }
@@ -65,16 +71,16 @@ public func reportIssue(
6571 case . swiftTesting:
6672 _recordIssue (
6773 message: message ( ) ,
68- fileID: " \( IssueContext . current ? . fileID ?? fileID) " ,
69- filePath: " \( IssueContext . current ? . filePath ?? filePath) " ,
70- line: Int ( IssueContext . current ? . line ?? line) ,
71- column: Int ( IssueContext . current ? . column ?? column)
74+ fileID: " \( fileID) " ,
75+ filePath: " \( filePath) " ,
76+ line: Int ( line) ,
77+ column: Int ( column)
7278 )
7379 case . xcTest:
7480 _XCTFail (
7581 message ( ) . withAppHostWarningIfNeeded ( ) ?? " " ,
76- file: IssueContext . current ? . filePath ?? filePath,
77- line: IssueContext . current ? . line ?? line
82+ file: filePath,
83+ line: line
7884 )
7985 @unknown default : break
8086 }
@@ -101,6 +107,12 @@ public func reportIssue(
101107 line: UInt = #line,
102108 column: UInt = #column
103109) {
110+ let ( fileID, filePath, line, column) = (
111+ IssueContext . current? . fileID ?? fileID,
112+ IssueContext . current? . filePath ?? filePath,
113+ IssueContext . current? . line ?? line,
114+ IssueContext . current? . column ?? column
115+ )
104116 guard let context = TestContext . current else {
105117 guard !isTesting else { return }
106118 if let observer = FailureObserver . current {
@@ -109,21 +121,21 @@ public func reportIssue(
109121 reporter. expectIssue (
110122 error,
111123 message ( ) ,
112- fileID: IssueContext . current ? . fileID ?? fileID,
113- filePath: IssueContext . current ? . filePath ?? filePath,
114- line: IssueContext . current ? . line ?? line,
115- column: IssueContext . current ? . column ?? column
124+ fileID: fileID,
125+ filePath: filePath,
126+ line: line,
127+ column: column
116128 )
117129 }
118130 } else {
119131 for reporter in IssueReporters . current {
120132 reporter. reportIssue (
121133 error,
122134 message ( ) ,
123- fileID: IssueContext . current ? . fileID ?? fileID,
124- filePath: IssueContext . current ? . filePath ?? filePath,
125- line: IssueContext . current ? . line ?? line,
126- column: IssueContext . current ? . column ?? column
135+ fileID: fileID,
136+ filePath: filePath,
137+ line: line,
138+ column: column
127139 )
128140 }
129141 }
@@ -135,16 +147,16 @@ public func reportIssue(
135147 _recordError (
136148 error: error,
137149 message: message ( ) ,
138- fileID: " \( IssueContext . current ? . fileID ?? fileID) " ,
139- filePath: " \( IssueContext . current ? . filePath ?? filePath) " ,
140- line: Int ( IssueContext . current ? . line ?? line) ,
141- column: Int ( IssueContext . current ? . column ?? column)
150+ fileID: " \( fileID) " ,
151+ filePath: " \( filePath) " ,
152+ line: Int ( line) ,
153+ column: Int ( column)
142154 )
143155 case . xcTest:
144156 _XCTFail (
145157 " Caught error: \( error) \( message ( ) . map { " : \( $0) " } ?? " " ) " . withAppHostWarningIfNeeded ( ) ,
146- file: IssueContext . current ? . filePath ?? filePath,
147- line: IssueContext . current ? . line ?? line
158+ file: filePath,
159+ line: line
148160 )
149161 @unknown default : break
150162 }
0 commit comments