Skip to content

Commit 1c5920e

Browse files
authored
fix: Use explicit Package.Dependency type to avoid Swift 6.2.3 circular reference bug (#11)
## Problem The pattern `.package(url:...)` inside `package.dependencies.append()` causes Swift 6.2.3 to confuse the member lookup with the `package` variable, resulting in a "circular reference" error. ## Solution Use the explicit type `Package.Dependency.package(url:...)` to avoid this ambiguity. ## Testing - Verified Package.swift parses correctly with Swift 6.2.3
1 parent df850a2 commit 1c5920e

4 files changed

Lines changed: 34 additions & 24 deletions

File tree

Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ let package = Package(
3030
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
3131
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
3232
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"),
33-
// NB: Fork with Swift 6.3 fixes (uses doozMen/swift-perception)
34-
.package(url: "https://github.com/doozMen/swift-sharing", branch: "main"),
33+
// NB: Fork with Swift 6.3 fixes
34+
.package(url: "https://github.com/doozMen/swift-sharing", branch: "fix/swift-623-optimizer-crash"),
3535
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.4"),
3636
// NB: Fork with Swift 6.3 fixes
3737
.package(
@@ -70,9 +70,6 @@ let package = Package(
7070
"SQLiteData",
7171
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
7272
.product(name: "CustomDump", package: "swift-custom-dump"),
73-
.product(name: "Perception", package: "swift-perception"),
74-
.product(name: "Sharing", package: "swift-sharing"),
75-
.product(name: "StructuredQueriesSQLite", package: "swift-structured-queries"),
7673
]
7774
),
7875
.testTarget(
@@ -82,7 +79,6 @@ let package = Package(
8279
"SQLiteDataTestSupport",
8380
.product(name: "DependenciesTestSupport", package: "swift-dependencies"),
8481
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
85-
package: "swift-tagged",
8682
.product(name: "SnapshotTestingCustomDump", package: "swift-snapshot-testing"),
8783
.product(name: "StructuredQueries", package: "swift-structured-queries"),
8884
]

Sources/SQLiteData/StructuredQueries+GRDB/Statement+GRDB.swift

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,29 @@ extension SelectStatement where QueryValue == (), Joins == () {
186186
}
187187
}
188188

189-
extension SelectStatement where QueryValue == (), From: PrimaryKeyedTable, Joins == () {
190-
/// Returns a single value fetched from the database for a given primary key.
191-
///
192-
/// - Parameters
193-
/// - db: A database connection.
194-
/// - primaryKey: A primary key identifying a table row.
195-
/// - Returns: A single value decoded from the database.
196-
@inlinable
197-
public func find(
198-
_ db: Database,
199-
key primaryKey: some QueryExpression<From.PrimaryKey>
200-
) throws -> From.QueryOutput {
201-
guard let record = try asSelect().find(primaryKey).fetchOne(db) else {
202-
throw NotFound()
189+
// NB: Swift 6.2.3 and 6.3-dev guard Select.find(_:) in swift-structured-queries due to compiler crashes.
190+
// This extension depends on that method, so it must also be guarded.
191+
// Tracking: https://github.com/swiftlang/swift/issues/82529
192+
#if !compiler(>=6.2.3)
193+
extension SelectStatement where QueryValue == (), From: PrimaryKeyedTable, Joins == () {
194+
/// Returns a single value fetched from the database for a given primary key.
195+
///
196+
/// - Parameters
197+
/// - db: A database connection.
198+
/// - primaryKey: A primary key identifying a table row.
199+
/// - Returns: A single value decoded from the database.
200+
@inlinable
201+
public func find(
202+
_ db: Database,
203+
key primaryKey: some QueryExpression<From.PrimaryKey>
204+
) throws -> From.QueryOutput {
205+
guard let record = try asSelect().find(primaryKey).fetchOne(db) else {
206+
throw NotFound()
207+
}
208+
return record
203209
}
204-
return record
205210
}
206-
}
211+
#endif
207212

208213
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
209214
extension SelectStatement where QueryValue == () {

Sources/SQLiteData/StructuredQueries+GRDB/Table+GRDB.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extension StructuredQueriesCore.PrimaryKeyedTable {
5555
try all.find(db, key: primaryKey)
5656
}
5757
}
58-
#/
58+
*/
5959

6060
// NB: Swift 6.2.3 and 6.3-dev guard Select.find(_:) in swift-structured-queries due to compiler crashes.
6161
// This extension depends on that method, so it must also be guarded.

0 commit comments

Comments
 (0)