Skip to content

Commit

Permalink
QueryEngine: Calculate stable hashes for Foundation.URL and Foundatio…
Browse files Browse the repository at this point in the history
…nEssentials.URL

Until Swift 6.0, the fully-qualified name of the URL type was
`Foundation.URL`.  After the adoption of FoundationEssentials, the
name changed to `FoundationEssentials.URL`.  This difference causes
the hashes to change, so for backwards compatibility we pin the
type name to `Foundation.URL`.

Fixes #45
  • Loading branch information
euanh committed Nov 8, 2024
1 parent bde8791 commit 542d515
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Helpers/Vendor/QueryEngine/CacheKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ extension FilePath.Component: LeafCacheKey {
extension URL: LeafCacheKey {
func hash(with hashFunction: inout some HashFunction) {
String(reflecting: Self.self).hash(with: &hashFunction)

// Until Swift 6.0, the fully-qualified name of the URL type was `Foundation.URL`.
// After the adoption of FoundationEssentials, the name changed to `FoundationEssentials.URL`.
// This difference causes the hashes to change, so for backwards compatibility we pin the
// type name to `Foundation.URL`.
"Foundation.URL".hash(with: &hashFunction)
self.description.hash(with: &hashFunction)
}
}

0 comments on commit 542d515

Please sign in to comment.