Commit Graph

2 Commits

Author SHA1 Message Date
Becca Royal-Gordon
956bd10be4 Prevent shadowing of unavailable member impls
Typically, access control denies access to member implementations, so the imported interface decl will be used instead. However, in contexts that permit direct access to stored properties—such as accessors, inits, and deinits—their member implementations are accessible; the compiler then relies on a shadowing rule favoring Swift decls over ObjC decls to eliminate the imported interface decl.

However, there are many rules that are higher-priority than the Swift vs. ObjC decls one. In particular, a recent change to availability checking in #77886 caused a higher-priority rule to begin eliminating member implementations which belonged to unavailable extensions. This caused regressions in projects using `@objc @implementation` with classes that are unavailable in Mac Catalyst.

Introduce a fairly high-priority shadowing rule that favors a member implementation over its interface when both are present (i.e. when direct access to storage is permitted).

Fixes rdar://143582383.
2025-01-31 21:01:06 -08:00
Becca Royal-Gordon
b70ecfaf31 Support objcImpl + implementationOnly
Member implementations are never directly visible to clients of a module, even if they are formally public, but TypeCheckAvailability did not know this. As a result, it would incorrectly diagnose member implementations in an objcImpl extension as violating @_implementationOnly import rules or other, similar access checks. This commit excludes them from being considered as exported declarations.

Fixes rdar://121229058.
2024-02-19 17:13:51 -08:00