Skip to content

Commit

Permalink
Fix multi-threaded access when generic types are generated
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulTaykalo committed Jul 22, 2024
1 parent 81033ec commit ec8f5c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions SourceryRuntime/Sources/Common/Composer/Composer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ public enum Composer {
public static func uniqueTypesAndFunctions(_ parserResult: FileParserResult, serial: Bool = false) -> (types: [Type], functions: [SourceryMethod], typealiases: [Typealias]) {
let composed = ParserResultsComposed(parserResult: parserResult)

let resolveTypeLock = NSLock()
let resolveType = { (typeName: TypeName, containingType: Type?) -> Type? in
composed.resolveType(typeName: typeName, containingType: containingType)
resolveTypeLock.withLock {
composed.resolveType(typeName: typeName, containingType: containingType)
}
}

let methodResolveType = { (typeName: TypeName, containingType: Type?, method: Method) -> Type? in
composed.resolveType(typeName: typeName, containingType: containingType, method: method)
resolveTypeLock.withLock {
composed.resolveType(typeName: typeName, containingType: containingType, method: method)
}
}

let processType = { (type: Type) in
Expand Down

0 comments on commit ec8f5c9

Please sign in to comment.