Skip to content

[Static Mirror] Handle anonymous contexts when re-constructing fully-qualified type names #42190

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

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Apr 5, 2022

Anonymous contexts (e.g. types nested inside functons) require special handling when we are constructing a fully-qualified name. We construct the name by walking from a type's descriptor to its parent contexts. Previously, we would give up upon encountering an anonymous contexts.

This change refactors fully-qualified name construction to happen in two phases:

  1. Collect a full context ancestor chain by walking up to parent contexts all the way up to the module.
  2. Walk the chain backwards to reconstruct the fully-qualified name
    As opposed to the previous approach which always constructed the name while recursively walking to the parent context. This is required because types nested inside anonymous contexts are represented in the fully-qualified type name as (type_name in $XXXXXXXX) where XXXXXXXX is the address of the context descriptor of the parent anonymous context.

Resolves rdar://91073103

@artemcm artemcm force-pushed the AnonymousContextFullyQualifiedTypeNameReconstruction branch 3 times, most recently from 62fae63 to be0958e Compare April 5, 2022 21:40
@artemcm
Copy link
Contributor Author

artemcm commented Apr 5, 2022

@swift-ci please test

@artemcm artemcm force-pushed the AnonymousContextFullyQualifiedTypeNameReconstruction branch from be0958e to cb27fe3 Compare April 6, 2022 23:54
@artemcm artemcm force-pushed the AnonymousContextFullyQualifiedTypeNameReconstruction branch 5 times, most recently from f28d1d8 to 6ccf8da Compare May 31, 2022 22:05
…qualified type names

Anonymous contexts (e.g. types nested inside functons) require special handling when we are constructing a fully-qualified name. We construct the name by walking from a type's descriptor to its parent contexts. Previously, we would give up upon encountering an anonymous contexts.

This change refactors fully-qualified name construction to happen in two phases:
1. Collect a full context ancestor chain
2. Walk the chain backwards to reconstruct the fully-qualified name
As opposed to the previous approach which always constructed the name while recursively walking to the parent context. This is required because types nested inside anonymous contexts are represented in the fully-qualified type name as `(type_name in $XXXXXXXX)` where XXXXXXXX is the address of the context descriptor of the parent anonymous context.

Resolves rdar://91073103
@artemcm artemcm force-pushed the AnonymousContextFullyQualifiedTypeNameReconstruction branch from 6ccf8da to bc79518 Compare May 31, 2022 22:56
@artemcm
Copy link
Contributor Author

artemcm commented Jun 1, 2022

@swift-ci please test

@artemcm artemcm marked this pull request as ready for review June 1, 2022 15:48
@artemcm artemcm requested a review from mikeash June 2, 2022 19:03
@artemcm artemcm merged commit ee312bc into swiftlang:main Jun 2, 2022
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