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