Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-3443] Extensions do not preserve sugar (like a typealias) of their base type #46031

Open
belkadan opened this issue Dec 16, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself serialization Area → compiler: Serialization & deserialization

Comments

@belkadan
Copy link
Contributor

Previous ID SR-3443
Radar None
Original Reporter @belkadan
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Serialization
Assignee None
Priority Medium

md5: d35dc1c42263a4b5788421755404ad94

Issue Description:

As of #6336 serializing an extension will deliberately desugar its base type first. This works around two issues:

  • The name of a non-public typealias would leak into the public interface if the extension had any public members.
  • A common pattern of defining a platform-specific typealias for an imported class and then extending that type would lead to circularity when trying to deserialize the typealias. We shouldn't be loading the extension at that point, but fixing that would be much harder.
typealias Foo = UIFoo // or NSFoo
extension Foo {}

The "right" answer is to (a) check that the typealias is public if the extension has any public members, and (b) somehow ensure there is no circularity issue (either by not importing the extension as a result of importing the typealias, or by the extension being able to set its sugared base type later).

If we ever solve these problems, we should restore the sugar, since it can make the extension clearer for clients of the library. The desugared form might be some unpretty implementation type that's not intended to be used directly.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself serialization Area → compiler: Serialization & deserialization
Projects
None yet
Development

No branches or pull requests

1 participant