Skip to content

[5.6][SE-0335] Enable explicit existential types. #40804

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

Merged
merged 25 commits into from
Jan 14, 2022

Conversation

hborla
Copy link
Member

@hborla hborla commented Jan 11, 2022

Cherry-pick of #40666

This change is critical for Swift 5.6 in order to stage in the transition to any over several major releases. This change allows any to be written in source code, but does not introduce warnings about the lack of any, per the acceptance decision of SE-0335:

the goal is that that one can write code that compiles without warnings for the current Swift release and at least one major release prior (possibly more, pending the above discussion), after which warnings can be introduced to guide users to the new syntax in existing language modes. Finally, the old syntax can be removed or repurposed only in a new major language version.

Resolves: rdar://86347236

hborla added 22 commits January 11, 2022 12:59
compositions in ExistentialType when explicit existentials are
enabled.
in ExistentialType for the type of error values.
…able

initializer requirements with explicit existential Encodable and Decodable
parameters.
finding the protocol decl for an existential type.
explicit ExistentialType.

The ASTDemangler needs to produce ExistentialType based on context, not
unconditionally when producing a protocol composition. This is tricky
because existential types are mangled the same way as other protocol
references, e.g. in conformance requirements. For now, drop the explicit
existentials when reconstructing types.
resolve to ProtocolType or ProtocolCompositionType are always existential
types.

This can happen because type aliases to protocol constraints can also be
used as type witnesses. The type alias itself is still a constraint,
because it can be used in generic signatures in addition to being used
as an existential type, e.g. in parameter position. So, we need to wrap
the type alias in an ExistentialType during type witness resolution.
metatypes always wrap the constraint type directly, and the instance
type of an existential metatype is an existential type.
existential types.

Use the correct type resolver context when resolving SIL metatypes
and function types, and diagnose an error if an explicit existential
type appears in a protocol composition.
various places that expect ProtocolType or ProtocoolCompositionType.
are printed with the `any` keyword.

For now, printing `any` is off by default in order to turn on explicit
existential types with minimal changes to the test suite. The option
will also allow control over how existential types are printed in
Swift interfaces.
There are places in the frontend that strip off ExistentialType from
a type, e.g. in the round-trip check for type reconstruction, which
is a valid transformation for SILBox types' substitutions because
it doesn't invalidate conformances.
@hborla
Copy link
Member Author

hborla commented Jan 12, 2022

swiftlang/llvm-project#3778

@swift-ci please test

@hborla
Copy link
Member Author

hborla commented Jan 12, 2022

@swift-ci please test source compatibility

@hborla hborla marked this pull request as ready for review January 12, 2022 00:26
@hborla hborla added the r5.6 label Jan 12, 2022
…Type

by propagating whether the decoded type is for a requirement through
TypeDecoder.
@hborla
Copy link
Member Author

hborla commented Jan 12, 2022

swiftlang/llvm-project#3778

@swift-ci please test

@hborla
Copy link
Member Author

hborla commented Jan 12, 2022

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - de8726e

@hborla
Copy link
Member Author

hborla commented Jan 13, 2022

None of the source compatibility failures look related to this change. All of the failing projects are XFAIL'd on main, and from what I can tell, the failures are the same here as they were with main.

@hborla
Copy link
Member Author

hborla commented Jan 13, 2022

swiftlang/llvm-project#3778

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - de8726e

@hborla
Copy link
Member Author

hborla commented Jan 13, 2022

swiftlang/llvm-project#3778

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - de8726e

@hborla
Copy link
Member Author

hborla commented Jan 14, 2022

swiftlang/llvm-project#3778

@swift-ci please clean test macOS platform

existential arguments to not return before checking the second
argument type.
…ence

when the member is a typealias to a protocol or composition.
@hborla hborla requested a review from a team as a code owner January 14, 2022 06:45
@hborla
Copy link
Member Author

hborla commented Jan 14, 2022

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - de8726e

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 8fe5396

@hborla
Copy link
Member Author

hborla commented Jan 14, 2022

@swift-ci please clean test Linux platform

@hborla hborla merged commit c12e31f into swiftlang:release/5.6 Jan 14, 2022
@hborla hborla deleted the 5.6-enable-existential-any branch January 14, 2022 20:54
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.6 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants