Skip to content

Commit 071ff06

Browse files
authored
Merge pull request #1371 from bnbarham/fix-generator-on-old-swifts
Fix code generation on older Swift versions
2 parents 1b8d5e9 + 1bae557 commit 071ff06

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CodeGeneration/Sources/Utils/SyntaxBuildableType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public struct SyntaxBuildableType: Hashable {
170170
}
171171

172172
/// Wraps a type in an optional chaining depending on whether `isOptional` is true.
173-
public func optionalChained(expr: ExprSyntaxProtocol) -> ExprSyntax {
173+
public func optionalChained<ExprNode: ExprSyntaxProtocol>(expr: ExprNode) -> ExprSyntax {
174174
if isOptional {
175175
return ExprSyntax(OptionalChainingExprSyntax(expression: expr))
176176
} else {
@@ -179,7 +179,7 @@ public struct SyntaxBuildableType: Hashable {
179179
}
180180

181181
/// Wraps a type in a force unwrap expression depending on whether `isOptional` is true.
182-
public func forceUnwrappedIfNeeded(expr: ExprSyntaxProtocol) -> ExprSyntax {
182+
public func forceUnwrappedIfNeeded<ExprNode: ExprSyntaxProtocol>(expr: ExprNode) -> ExprSyntax {
183183
if isOptional {
184184
return ExprSyntax(ForcedValueExprSyntax(expression: expr))
185185
} else {

CodeGeneration/Sources/generate-swiftsyntax/GenerateSwiftSyntax.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ struct GenerateSwiftSyntax: ParsableCommand {
120120
.appendingPathComponent(template.module)
121121
.appendingPathComponent("generated")
122122
.appendingPathComponent(template.filename)
123-
previouslyGeneratedFilesLock.withLock {
124-
_ = previouslyGeneratedFiles.remove(destination)
125-
}
123+
124+
previouslyGeneratedFilesLock.lock();
125+
_ = previouslyGeneratedFiles.remove(destination)
126+
previouslyGeneratedFilesLock.unlock()
127+
126128
try generateTemplate(
127129
sourceFile: template.sourceFile,
128130
destination: destination,

0 commit comments

Comments
 (0)