mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In https://github.com/swiftlang/swift/pull/78454 queries for the platform availability of decl were consolidated into `Decl::getAvailableAttrForPlatformIntroduction()`. In addition to checking the attributes directly attached to the decl, this method also checks whether the decl is a member directly contained inside of an extension and checks for attributes attached to the extension as well. Previously, this logic was only used for availability checking diagnostics, where special casing extension members was a requirement. As a result of the consolidation, though, the logic is now also shared by the query that determines whether to weakly link symbols associated with a decl. That determination already had its own way of handling members of extensions but it seemed like consolidating the logic would stil be a net improvement that would reduce overall complexity. Unfortunately, the existing approach to getting the availability of the enclosing extension had a subtle bug for both AccessorDecl and OpaqueTypeDecl. If an AvailableAttr was not directly attached to the immediate decl, then `Decl::getAvailableAttrForPlatformIntroduction()` would check if the enclosing decl context was an extension and look at its attributes as well. For AccessorDecl and OpaqueTypeDecl, checking the enclosing decl context would accidentally skip over the VarDecl and AbstractFunctionDecl that are formally the parents of those decls for the purposes of attribute inheritance. As a result, the availability of the enclosing property or function could be ignored if the enclosing extension had explicit availability attributes. The fix is to use `AvailabilityInference::parentDeclForInferredAvailability()` instead of `getDeclContext()` when looking for the immediately enclosing extension. Resolves rdar://143139472.
8.1 KiB
8.1 KiB