Skip to content

Commit 16d502e

Browse files
committed
Fix typed-throws compilation issue with Swift 6.2
1 parent fc2aeda commit 16d502e

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Source/Stubbing/Stub.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ public protocol Stub {
22
var method: String { get }
33
}
44

5-
public class ConcreteStub<IN, OUT, ERROR>: Stub {
5+
public class ConcreteStub<IN, OUT, ERROR: Error>: Stub {
66
public let method: String
77
let parameterMatchers: [ParameterMatcher<IN>]
88
var actions: [StubAction<IN, OUT, ERROR>] = []
@@ -17,4 +17,4 @@ public class ConcreteStub<IN, OUT, ERROR>: Stub {
1717
}
1818
}
1919

20-
public class ClassConcreteStub<IN, OUT, ERROR>: ConcreteStub<IN, OUT, ERROR> { }
20+
public class ClassConcreteStub<IN, OUT, ERROR: Error>: ConcreteStub<IN, OUT, ERROR> { }

Source/Stubbing/StubAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum StubAction<IN, OUT, ERROR> {
1+
enum StubAction<IN, OUT, ERROR: Error> {
22
case callImplementation((IN) throws(ERROR) -> OUT)
33
case returnValue(OUT)
44
case throwError(ERROR)

Tests/Swift/Source/TestedClass.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ class TestedClass {
214214
func withReservedKeywords(for: String, in: String) -> String {
215215
"hello"
216216
}
217+
218+
func withTypedThrows() throws(NSError) {}
217219

218220
func callingCountCharactersMethodWithHello() -> Int {
219221
return count(characters: "Hello")

Tests/Swift/Stubbing/StubThrowingFunctionTest.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ final class StubThrowingFunctionTest: XCTestCase {
6666

6767
XCTAssertTrue(catched)
6868
}
69+
70+
func testTypedThrowsThenTypedError() {
71+
let mock = MockTestedClass()
72+
stub(mock) { mock in
73+
when(mock.withTypedThrows())
74+
.thenThrow(NSError())
75+
}
76+
}
6977

7078
private enum TestError: Error {
7179
case unknown

0 commit comments

Comments
 (0)