From 542d51515f99582663583c9d6b745db115b6fc9c Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Fri, 8 Nov 2024 13:52:04 +0000 Subject: [PATCH] QueryEngine: Calculate stable hashes for Foundation.URL and FoundationEssentials.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 --- Sources/Helpers/Vendor/QueryEngine/CacheKey.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift b/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift index c09b0de..4e72aa7 100644 --- a/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift +++ b/Sources/Helpers/Vendor/QueryEngine/CacheKey.swift @@ -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) } }