Use of function refers to instance method rather than global function

I am reading SE-0313 (Improved control over actor isolation), and trying to compile the following code.

enum ActorIsolationControl {
    static func main () async throws {
        let u = BankAccount (accountNumber: 0, initialDeposit: 0)

// []

actor BankAccount {
    let accountNumber: Int
    var balance: Double

    init (accountNumber: Int, initialDeposit: Double) {
        self.accountNumber = accountNumber
        self.balance = initialDeposit

    func deposit (amount: Double) {
        assert(amount >= 0)
        balance = balance + amount

func deposit (amount: Double, to account: isolated BankAccount) {
    assert(amount >= 0)
    account.balance = account.balance + amount

extension BankAccount {
    func giveSomeGetSome (amount: Double, friend: BankAccount) async {
        deposit (amount: amount, to: self)         // okay to call synchronously, because self is isolated
        await deposit (amount: amount, to: friend) // must call asynchronously, because friend is not isolated

However, I am getting some errors in func giveSomeGetSome (...)

Use of 'deposit' refers to instance method rather than global function 'deposit(amount:to:)' in module Test

Use 'Test.' to reference the global function in module 'Test'

But why? Isn't the global function's signature distinct enough to eliminate ambiguity?

The same issue was discussed in this thread from 2023-05: Global functions can't be used if a member function shadows its name, even if the argument labels are different

1 Like