Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw committed Jul 22, 2024
1 parent e870465 commit c11e1c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Sources/Dependencies/DependencyValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ private final class CachedValues: @unchecked Sendable {
function: StaticString = #function,
line: UInt = #line
) -> Key.Value {
lock.lock()
defer { lock.unlock() }

XCTFailContext.$current.withValue(XCTFailContext(file: file, line: line)) {
let cacheKey = CacheKey(id: ObjectIdentifier(key), context: context)
guard let base = cached[cacheKey], let value = base as? Key.Value
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependenciesTests/CacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class CachedValueTests: XCTestCase {
struct OuterDependencyTests: TestDependencyKey {
static var testValue: OuterDependencyTests {
@Dependency(InnerDependency.self) var innerDependency
innerDependency.perform()
_ = innerDependency
return Self()
}
}
Expand Down

0 comments on commit c11e1c0

Please sign in to comment.