This compiles, taking advantage of SE-0347: Type inference from default expressions:
struct MyTask {
func sleep<C: Clock>(
until deadline: C.Instant,
clock: C = ContinuousClock()
) async throws {}
}
But: the same function signature as a free function doesn't compile:
func sleep<C: Clock>(
until deadline: C.Instant,
// ❌: Cannot use default expression for inference of 'C'
// because it is inferrable from parameters #0, #1
clock: C = ContinuousClock()
) async throws {}
Observed with Xcode 15.3 (Swift 5.10).
This looks like a bug, doesn't it? Or am I missing anything? /cc @xedin