swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.72k stars 1.34k forks source link

Move PackageCollectionsProtocol to async/await #7726

Closed AndrewHoos closed 3 months ago

AndrewHoos commented 3 months ago

Move PackageCollectionsProtocol to async/await

Motivation:

async/await is easier to read and reason about then the callback APIs

Modifications:

PackageCollectionsProtocol is now expressed in terms of async methods instead of callbacks callback to async bridge methods are removed Replaced usage of DispatchGroup with async let PackageMetadata init has default values for optional and array values

Result:

More readable code

MaxDesiatov commented 3 months ago

@swift-ci test

rauhul commented 3 months ago

❤️ negative diff PRs

AndrewHoos commented 3 months ago
/home/build-user/swiftpm/Sources/PackageCollections/PackageCollections.swift:343:22: error: cannot find 'withCheckedContinuation' in scope
341 |         let packageSearchResult = try await self.findPackage(identity: identity, location: location, collections: collections)
342 |         // then try to get more metadata from provider (optional)
343 |         return await withCheckedContinuation { continuation in
    |                      `- error: cannot find 'withCheckedContinuation' in scope
344 |             self.metadataProvider.get(identity: packageSearchResult.package.identity, location: packageSearchResult.package.location) { result, provider in
345 |                 switch result {
AndrewHoos commented 3 months ago

Something odd with importing _Concurrency seems to break on Linux?

MaxDesiatov commented 3 months ago

import _Concurrency is required when building with CMake.

MaxDesiatov commented 3 months ago

@swift-ci test

MaxDesiatov commented 3 months ago

@swift-ci test windows

MaxDesiatov commented 3 months ago

@ahoppen could the macOS failure be related to recent SourceKit-LSP changes?

error: value of type 'SourceKitLSPOptions' has no member 'swiftSDK'
AndrewHoos commented 3 months ago

@swift-ci test