tgrapperon/swift-dependencies-additions

Overriding dependencies on @FunctionProxy's fail when they accept a parameter

DandyLyons opened this issue · 0 comments

I don't understand the cause of this but when I put this in my test, it refuses to build:

await withDependencies {
            $0.userNotificationCenter.$add = { @Sendable userNotificationRequest in
                await requests.setValue([userNotificationRequest])
            }
        } operation: {
           // ...
        }

Xcode provides no error other than Command SwiftCompile failed with a nonzero exit code. (I did also clean my build folder and clear derived data folder). After much sleuthing I found that the offending line was this:

           $0.userNotificationCenter.$add = { @Sendable userNotificationRequest in
                await requests.setValue([userNotificationRequest])
            }

When I remove it, the test builds. When I assign it as a variable rather than inline, then it builds.

let add = { @Sendable userNotificationRequest in
                await requests.setValue([userNotificationRequest])
            }
            $0.userNotificationCenter.$add = add // this builds

Is this a bug, or am I using something wrong?

You can see the full code at: https://github.com/DandyLyons/BrittanyArima-Steps/blob/31-add-unit-tests/StepsTests/SettingsViewTests.swift