Skip to content

Commit e1b9f50

Browse files
committed
.swift-format: Enable NoVoidReturnOnFunctionSignature
1 parent c4f53b3 commit e1b9f50

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.swift-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"UseLetInEveryBoundCaseVariable": false,
1616
"UseSynthesizedInitializer": false,
1717
"ReturnVoidInsteadOfEmptyTuple": true,
18+
"NoVoidReturnOnFunctionSignature": true,
1819
}
1920
}

Examples/Sources/MacroExamples/Implementation/Peer/AddAsyncMacro.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public struct AddAsyncMacro: PeerMacro {
4242
}
4343

4444
// This only makes sense void functions
45-
if funcDecl.signature.returnClause?.type.as(IdentifierTypeSyntax.self)?.name.text != "Void" {
45+
if let returnClause = funcDecl.signature.returnClause,
46+
returnClause.type.as(IdentifierTypeSyntax.self)?.name.text != "Void"
47+
{
4648
throw CustomError.message(
4749
"@addAsync requires an function that returns void"
4850
)

Examples/Sources/MacroExamples/Playground/PeerMacrosPlayground.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func runPeerMacrosPlayground() {
1717

1818
struct MyStruct {
1919
@AddAsync
20-
func c(a: Int, for b: String, _ value: Double, completionBlock: @escaping (Result<String, Error>) -> Void) -> Void {
20+
func c(a: Int, for b: String, _ value: Double, completionBlock: @escaping (Result<String, Error>) -> Void) {
2121
completionBlock(.success("a: \(a), b: \(b), value: \(value)"))
2222
}
2323

2424
@AddAsync
25-
func d(a: Int, for b: String, _ value: Double, completionBlock: @escaping (Bool) -> Void) -> Void {
25+
func d(a: Int, for b: String, _ value: Double, completionBlock: @escaping (Bool) -> Void) {
2626
completionBlock(true)
2727
}
2828
}

0 commit comments

Comments
 (0)