Skip to content

[5.7][Sema] Use ExistentialType for Any and AnyObject.#59657

Merged
hborla merged 4 commits intoswiftlang:release/5.7from
hborla:5.7-existential-any-anyobject
Jun 25, 2022
Merged

[5.7][Sema] Use ExistentialType for Any and AnyObject.#59657
hborla merged 4 commits intoswiftlang:release/5.7from
hborla:5.7-existential-any-anyobject

Conversation

@hborla
Copy link
Copy Markdown
Member

@hborla hborla commented Jun 23, 2022

Cherry-pick of #41909

Note that the main PR is not merged yet because passing lldb tests depends on an lldb change that has to land on llvm-project:swift/release/5.7 first.

  • Explanation: This change models existential Any and AnyObject using ExistentialType, just like all other existential types. Previously, these two existential types still were modeled with ProtocolCompositionType because they're not required to be written with any, but this allowed using any on these types in conformance constraint context, e.g.
func generic<T>(value: T) where T: any Any { ... } // okay??

This also caused type resolution to not know the difference between (any Any).Type and any Any.Type, as described in #58367.

Note that Any and AnyObject still do not print with any in the ASTPrinter, except when it's needed to distinguish between the existential metatype and the singleton metatype, e.g. any Any.Type vs (any Any).Type.

  • Scope: This affects the frontend representation of code using Any and AnyObject as existential types.
  • Risk: Low.
  • Testing: Passed CI tests and the source compatibility suite. The ExistentialType representation itself has already been shipped in Swift 5.6 and thoroughly tested.
  • Reviewer: @slavapestov

Resolves: rdar://94370283, #58367

@hborla
Copy link
Copy Markdown
Member Author

hborla commented Jun 23, 2022

swiftlang/llvm-project#4863

@swift-ci please test

@hborla
Copy link
Copy Markdown
Member Author

hborla commented Jun 23, 2022

@swift-ci please test source compatibility

@hborla
Copy link
Copy Markdown
Member Author

hborla commented Jun 24, 2022

swiftlang/llvm-project#4863

@swift-ci please test

@hborla
Copy link
Copy Markdown
Member Author

hborla commented Jun 24, 2022

swiftlang/llvm-project#4882

@swift-ci please test

@hborla hborla merged commit a505698 into swiftlang:release/5.7 Jun 25, 2022
@hborla hborla deleted the 5.7-existential-any-anyobject branch June 25, 2022 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants