You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-7622 Non-public typealias should be exported as public equivalent when possible
Issue Description:
This is, as I recently discovered, correct behavior. However, it is not logical to apply this warning to type aliases for >=public types, since they can be exposed as the canonical type for the consumer.
internaltypealiasT = BoolpublicclassFoo<U> {}
publicclassBoolFoo: Foo<T> {} // Class should not be declared public because its superclass is internal
The text was updated successfully, but these errors were encountered:
This is correct behavior too. Being public means that your declaration is shown to clients in other modules. They have to be able to see all the types involved!
@belkadan Does meaningful here mean "the typealias can be substituted with the type it refers to without violating the access level of that type"?
I still don't quite get why an inaccessible typealias can't be thrown away for the consumer in favor of the type it refers to if that type is accessible for the user.
For instance, the developer wants to use an alias for a complex public type within the module for readability, but doesn't want to expose that alias to the consumer. I know this isn't a strong use case, but even so, does it really make sense for functions and types to become inaccessible just because a typealias in their signature is itself inaccessible?
There's no way for the compiler to tell the difference between "I'm using this for my convenience" and "I'm trying to show this to users but forgot it was internal". Right now there's a consistent rule, if restrictive. If you're interested in changing this, bring it up on the Swift Evolution forums.
Environment
Xcode 9.3 (9E145), 9.4 beta
Additional Detail from JIRA
md5: d0e9140caa531f2e87bfe28af94db6f7
relates to:
Issue Description:
This is, as I recently discovered, correct behavior. However, it is not logical to apply this warning to type aliases for >=public types, since they can be exposed as the canonical type for the consumer.
The text was updated successfully, but these errors were encountered: