groue / GRDB.swift

A toolkit for SQLite databases, with a focus on application development
MIT License
6.86k stars 708 forks source link

XCode warns "No 'async' operations occur within 'await' expression" #1594

Closed gfreezy closed 2 months ago

gfreezy commented 2 months ago

What did you do?

image

What did you expect to happen?

it should be no warning.

What happened instead?

XCode warns about:

No 'async' operations occur within 'await' expression

Environment

GRDB flavor(s): GRDB GRDB version: 6.29.1 Installation method: SPM Xcode version: 16.0 beta 5 Swift version: swift 6 Platform(s) running GRDB: iOS macOS version running Xcode: 14.5

groue commented 2 months ago

Hello @gfreezy,

The async version of GRDB read(_:) requires an @escaping closure. Your own read(value:) should require an @escaping closure as well:

static func read<T>(value: @escaping (Database) throws -> T) async throws -> T {
//                         ~~~~~~~~~

Please update your code, and report if this change removes the warning.

gfreezy commented 2 months ago

@escaping is not enough. After adding @Sendalbe @escape, it works.

Seems the document is outdated. There is no @Sendable in the document.

image