mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Within Swift 6.0, we expanded an optimization for witness tables that that allowed direct access to the witness table for conformances to any protocol that can never have a witness table, rather than requiring access through `swift_getWitnessTable` that might need to instantiate the witness table. The previous optimization only covered Objective-C protocols, but Swift 6.0 expanded that to marker protocols (such as `Sendable`) as well. However, this constituted an API break when a Swift 6.0 compiler uses a witness table that comes from a library built with an earlier version of Swift, when the protocol inherits from Sendable but the conformance to that protocol otherwise does not require an instantiation function. In such cases, Swift 6.0 would generate code that directly accesses the uninstantiated witness table symbol, which will have NULL entries for any conformance in it that was considered "dependent" by the earlier Swift compiler. Introduce a deployment target check to guard the new optimization. Specifically, when building for a deployment target that predates Swift 6.0, treat conformances to marker protocols as if they might be dependent (so the access patterns go through `swift_getWitnessTable` for potential instantiation on older platforms). For newer deployment targets, use the more efficent direct access pattern. Fixes rdar://133157093.
1.2 KiB
1.2 KiB