Skip to content

Commit 75f739f

Browse files
authored
Disfavor another unimplemented deprecation (#123)
* Disfavor another `unimplemented` deprecation When XCTestDynamicOverlay and IssueReporting are both imported into a file, the deprecated version takes precedence in certain situations, triggering a warning. This PR should address. * fix
1 parent 3788750 commit 75f739f

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

Examples/ExamplesTests/SwiftTestingTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
withKnownIssue {
1414
reportIssue()
1515
} matching: { issue in
16-
issue.description == "Expectation failed: "
16+
issue.description == "Issue recorded"
1717
}
1818
}
1919

2020
@Test func reportIssue_CustomMessage() {
2121
withKnownIssue {
2222
reportIssue("Something went wrong")
2323
} matching: { issue in
24-
issue.description == "Expectation failed: Something went wrong"
24+
issue.description == "Issue recorded: Something went wrong"
2525
}
2626
}
2727

Sources/XCTestDynamicOverlay/Internal/Deprecations.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public var XCTCurrentTestCase: AnyObject? {
251251
}
252252

253253
@_disfavoredOverload
254-
@available(*, deprecated, renamed: "unimplemented(_:placeholder:)")
254+
@available(*, unavailable, renamed: "unimplemented(_:placeholder:)")
255255
public func unimplemented<Result>(
256256
_ description: @autoclosure @escaping @Sendable () -> String = "",
257257
file filePath: StaticString = #filePath,
@@ -260,23 +260,10 @@ public func unimplemented<Result>(
260260
line: UInt = #line,
261261
column: UInt = #column
262262
) -> Result {
263-
let description = description()
264-
_fail(
265-
description,
266-
nil,
267-
fileID: fileID,
268-
filePath: filePath,
269-
function: function,
270-
line: line,
271-
column: column
272-
)
273-
do {
274-
return try _generatePlaceholder()
275-
} catch {
276-
_unimplementedFatalError(description, file: filePath, line: line)
277-
}
263+
fatalError()
278264
}
279265

266+
@_disfavoredOverload
280267
@available(*, deprecated, renamed: "unimplemented(_:placeholder:)")
281268
public func unimplemented<each Argument, Result>(
282269
_ description: @autoclosure @escaping @Sendable () -> String = "",

Tests/IssueReportingTests/UnimplementedTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,34 @@
122122
"""
123123
}
124124
}
125+
126+
@MainActor
127+
@Test func mainActor() throws {
128+
final class Model: Sendable {
129+
let line = #line + 1
130+
let callback: @Sendable @MainActor () throws -> Void = IssueReporting.unimplemented()
131+
}
132+
133+
let model = Model()
134+
try withKnownIssue {
135+
try withKnownIssue {
136+
_ = try model.callback()
137+
} matching: { issue in
138+
issue.description == """
139+
Issue recorded: Unimplemented …
140+
141+
Defined in 'Model' at:
142+
IssueReportingTests/UnimplementedTests.swift:\(model.line)
143+
144+
Invoked with:
145+
()
146+
"""
147+
}
148+
} matching: { issue in
149+
issue.description == """
150+
Caught error: UnimplementedFailure(description: "")
151+
"""
152+
}
153+
}
125154
}
126155
#endif

Tests/XCTestDynamicOverlayTests/TestHelpers.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,11 @@ struct User { let id: UUID }
110110
@available(*, deprecated)
111111
@MainActor let fm01: @MainActor () -> Int = unimplemented("fm01")
112112

113-
@available(*, deprecated)
114113
private struct Autoclosing {
115114
init(
116-
_: @autoclosure () -> Int = unimplemented(),
117-
_: @autoclosure () async -> Int = unimplemented(),
118-
_: @autoclosure () throws -> Int = unimplemented(),
119-
_: @autoclosure () async throws -> Int = unimplemented()
115+
_: @autoclosure () -> Int = unimplemented(placeholder: 0),
116+
_: @autoclosure () async -> Int = unimplemented(placeholder: 0),
117+
_: @autoclosure () throws -> Int = unimplemented(placeholder: 0),
118+
_: @autoclosure () async throws -> Int = unimplemented(placeholder: 0)
120119
) async {}
121120
}

0 commit comments

Comments
 (0)