Skip to content

Commit f4dafc2

Browse files
committed
fixing unwrap
1 parent 9dffdc2 commit f4dafc2

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

.swiftlint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ opt_in_rules:
7777
- strong_iboutlet
7878
- toggle_bool
7979
# - trailing_closure
80-
- type_contents_order
80+
# - type_contents_order
8181
- unavailable_function
8282
- unneeded_parentheses_in_closure_argument
8383
- unowned_variable_capture
@@ -120,7 +120,7 @@ excluded:
120120
- Mint
121121
- Examples
122122
- Macros
123-
- Sources/SyntaxKit/parser
123+
- Sources/SyntaxKit/Parser
124124
indentation_width:
125125
indentation_width: 2
126126
file_name:

Sources/SyntaxKit/Expressions/Closure.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Permission is hereby granted, free of charge, to any person
99
// obtaining a copy of this software and associated documentation
10-
// files (the Software), to deal in the Software without
10+
// files (the "Software"), to deal in the Software without
1111
// restriction, including without limitation the rights to use,
1212
// copy, modify, merge, publish, distribute, sublicense, and/or
1313
// sell copies of the Software, and to permit persons to whom the
@@ -17,7 +17,7 @@
1717
// The above copyright notice and this permission notice shall be
1818
// included in all copies or substantial portions of the Software.
1919
//
20-
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2121
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2222
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2323
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -125,6 +125,14 @@ public struct Closure: CodeBlock {
125125
)
126126
}
127127

128+
// Prepare return clause safely
129+
let returnClause: ReturnClauseSyntax? = returnType.map {
130+
ReturnClauseSyntax(
131+
arrow: .arrowToken(trailingTrivia: .space),
132+
type: $0.typeSyntax
133+
)
134+
}
135+
128136
let signature: ClosureSignatureSyntax? =
129137
(parameters.isEmpty && returnType == nil && capture.isEmpty && attributes.isEmpty)
130138
? nil
@@ -171,12 +179,7 @@ public struct Closure: CodeBlock {
171179
)
172180
),
173181
effectSpecifiers: nil,
174-
returnClause: returnType == nil
175-
? nil
176-
: ReturnClauseSyntax(
177-
arrow: .arrowToken(trailingTrivia: .space),
178-
type: returnType!.typeSyntax
179-
),
182+
returnClause: returnClause,
180183
inKeyword: .keyword(.in, leadingTrivia: .space, trailingTrivia: .space)
181184
)
182185

0 commit comments

Comments
 (0)