Actor access in static let

There seems to be a spurious warning when accessing properties of an actor within a static let statement. Here's some simple code that works as expected:

actor Actor { var value = 0 }
let a = Actor()
let isolated: @Sendable () async -> Int = {
  await a.value
}

As you would expect, the actor can be referenced in the sendable closure, and getting at value requires await. Now stuff the same logic into a static let declaration:

actor Actor { var value = 0 }
let a = Actor()
extension Int {
  static let isolated: @Sendable () async -> Int = {
    await a.value
// 👆 No 'async' operations occur within 'await' expression
  }
}

You get a warning that the await keyword isn't necessary. Changing the 'let' declaration to a computed property does not produce the warning. Is this a bug or did I miss something? I'm using Xcode 16 beta 1 in swift 6 language mode.

2 Likes