@@ -636,7 +636,36 @@ public struct URL : ReferenceConvertible, Equatable {
636
636
return _url. hash
637
637
}
638
638
639
+ @_alwaysEmitIntoClient // Introduced in 5.1
639
640
public func hash( into hasher: inout Hasher ) {
641
+ // We expect this function to eventually satisfy the corresponding
642
+ // requirement when URL starts conforming to Hashable. However, in the
643
+ // meantime, it is useful to provide it so that user code can simply
644
+ // declare the conformance if desired, without implementing anything.
645
+ //
646
+ // We want this definition to be available to all clients, even those
647
+ // that get deployed with the 5.0 Foundation overlay where URL did not
648
+ // provide this method. The `@_alwaysEmitIntoClient` attribute above
649
+ // forces this function to get compiled into any user code that uses it.
650
+ if #available( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * ) {
651
+ // When we're on recent enough ABI, we forward the call to the
652
+ // resilient implementation provided below. The availability check
653
+ // above guarantees that the entry point will exist in the library
654
+ // we link with.
655
+ _hash ( into: & hasher)
656
+ } else {
657
+ // This is the hash encoding that gets used with the 5.0 ABI. It has
658
+ // to match the version of == implemented by 5.0, so it shouldn't
659
+ // ever be changed.
660
+ hasher. combine ( _bridgeToObjectiveC ( ) )
661
+ }
662
+ }
663
+
664
+ @usableFromInline
665
+ @available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
666
+ internal func _hash( into hasher: inout Hasher ) {
667
+ // This code is beyond a resilience boundary. It has to be kept in
668
+ // sync with the definition of == implemented below.
640
669
hasher. combine ( _url)
641
670
}
642
671
0 commit comments