Self captured implicitly in tasks

Why am I not getting an error for missed self capture in tasks?

    class C {
        func bar() {}
        func foo() {
            DispatchQueue.main.async {
                bar() // expected error
                self.bar() // ok
            }
        }
        Task {
            bar() // fine?!
        }
    }

Specifically, the @_implicitSelfCapture attribute. Ultimately the behavior goes all the way back to the original proposal.

But that's a foot gun, no? Example:

    DispatchQueue.main.asyncAfter(deadline: .now() + 60) {
        bar() // Call to method 'bar' in closure requires explicit use of 'self' to make capture semantics explicit
    }

Being prompted with this error I may want to do a fix:

    DispatchQueue.main.asyncAfter(deadline: .now() + 60) { [weak self] in
        guard let self else {
            print("won't do anything, it's too late")
            return
        }
        self.bar()
    }

whilst here it just compiles fine, so I am not alerted:

    Task {
        try await Task.sleep(for: .seconds(60))
        bar() // hmm
    }

If I were alerted I could have preferred this instead:

    Task { [weak self] in
        try await Task.sleep(for: .seconds(60))
        guard let self else {
            print("won't do anything, it's too late")
            return
        }
        self.bar()
    }

You can read the original Task proposal and review thread to see why, but the scenario you point out was considered rare and the API was designed to make the common case even lighter weight.

I don't find the proposal convincing either. E.g.:

The closure passed to Task is executed immediately

"immediately"? Probably "soon"? but definitely not "synchronously". The same could be said about a closure passed to, say, DispatchQueue.global().async closure, but that doesn't have this behaviour.

Note : The same applies to the closure passed to Task.detached and TaskGroup.addTask .

This is not what I see implemented at the moment (Task.detached / addTask closure does require explicit self capturing).

IMHO this "implicit self" exception makes the language more complicated and less consistent overall.