Skip to content

Commit 73c36d2

Browse files
Fix warnings
1 parent 5ee55d3 commit 73c36d2

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

Sources/SpyableMacro/Extensions/TypeSyntax+Extensions.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,17 @@ extension GenericArgumentClauseSyntax: TypeSyntaxSupportingGenerics {
131131
newArgument = type.erasingGenericTypes(genericTypes)
132132
default: continue
133133
}
134+
let newArgumentElement = GenericArgumentSyntax(
135+
argument: .type(newArgument),
136+
trailingComma: argumentElement.trailingComma
137+
)
134138
#else
135139
let newArgument: TypeSyntax = argumentElement.argument.erasingGenericTypes(genericTypes)
140+
let newArgumentElement = GenericArgumentSyntax(
141+
argument: newArgument,
142+
trailingComma: argumentElement.trailingComma
143+
)
136144
#endif
137-
let newArgumentElement = GenericArgumentSyntax(
138-
argument: newArgument,
139-
trailingComma: argumentElement.trailingComma
140-
)
141145
newArgumentElements.append(newArgumentElement)
142146
}
143147

Sources/SpyableMacro/Factories/ClosureFactory.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct ClosureFactory {
4848
},
4949
effectSpecifiers: TypeEffectSpecifiersSyntax(
5050
asyncSpecifier: functionSignature.effectSpecifiers?.asyncSpecifier,
51-
throwsSpecifier: functionSignature.effectSpecifiers?.throwsSpecifier
51+
throwsClause: functionSignature.effectSpecifiers?.throwsClause
5252
),
5353
returnClause: returnClause
5454
)
@@ -166,7 +166,14 @@ struct ClosureFactory {
166166
expression = AwaitExprSyntax(expression: expression)
167167
}
168168

169-
if functionSignature.effectSpecifiers?.throwsSpecifier != nil {
169+
170+
#if canImport(SwiftSyntax600)
171+
let throwsSpecifier = functionSignature.effectSpecifiers?.throwsClause?.throwsSpecifier
172+
#else
173+
let throwsSpecifier = functionSignature.effectSpecifiers?.throwsSpecifier
174+
#endif
175+
176+
if throwsSpecifier != nil {
170177
expression = TryExprSyntax(expression: expression)
171178
}
172179

@@ -188,12 +195,16 @@ struct ClosureFactory {
188195

189196
extension FunctionParameterListSyntax.Element {
190197
fileprivate var isInoutParameter: Bool {
191-
if let attributedType = self.type.as(AttributedTypeSyntax.self),
192-
attributedType.specifier?.text == TokenSyntax.keyword(.inout).text
193-
{
194-
return true
195-
} else {
198+
guard let attributedType = self.type.as(AttributedTypeSyntax.self) else {
196199
return false
197200
}
201+
202+
#if canImport(SwiftSyntax600)
203+
let specifier = attributedType.specifiers.first?.firstToken(viewMode: .all)?.text
204+
#else
205+
let specifier = attributedType.specifier?.text
206+
#endif
207+
208+
return specifier == TokenSyntax.keyword(.inout).text
198209
}
199210
}

Sources/SpyableMacro/Factories/FunctionImplementationFactory.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ struct FunctionImplementationFactory {
8787
)
8888
}
8989

90-
if protocolFunctionDeclaration.signature.effectSpecifiers?.throwsSpecifier != nil {
90+
#if canImport(SwiftSyntax600)
91+
let throwsSpecifier = protocolFunctionDeclaration.signature.effectSpecifiers?.throwsClause?.throwsSpecifier
92+
#else
93+
let throwsSpecifier = protocolFunctionDeclaration.signature.effectSpecifiers?.throwsSpecifier
94+
#endif
95+
96+
if throwsSpecifier != nil {
9197
throwableErrorFactory.throwErrorExpression(variablePrefix: variablePrefix)
9298
}
9399

Sources/SpyableMacro/Factories/SpyFactory.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,14 @@ struct SpyFactory {
157157
parameterList: parameterList
158158
)
159159
}
160+
161+
#if canImport(SwiftSyntax600)
162+
let throwsSpecifier = functionDeclaration.signature.effectSpecifiers?.throwsClause?.throwsSpecifier
163+
#else
164+
let throwsSpecifier = functionDeclaration.signature.effectSpecifiers?.throwsSpecifier
165+
#endif
160166

161-
if functionDeclaration.signature.effectSpecifiers?.throwsSpecifier != nil {
167+
if throwsSpecifier != nil {
162168
try throwableErrorFactory.variableDeclaration(variablePrefix: variablePrefix)
163169
}
164170

0 commit comments

Comments
 (0)