Skip to content

5.9 [RemoteMirror] Fix lookup of generic type parameters #65524

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

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Apr 29, 2023

Explanation: Fixes lookup of generic type parameters for nested generics, partially reverts #62854 which attempted to fix the same issue in a different way
Risk: Only affects RemoteMirror library for a particular type structure that crashes without this fix
Reviewed by: @augusto2112 @mikeash
Resolves: rdar://106790077
Original PR: #65332
Tests: Added new unit tests for this specific case

tbkka added 6 commits April 28, 2023 17:54
…hen building decl"

(Keeps the test, but reverts the code changes; the test will be updated later.)

This reverts most of commit 893d83b from PR swiftlang#62854
This is a more correct fix for the issue that inspired PR swiftlang#62854.
In particular, this does not change the numbering of generic
argument levels, and so does not break generic type parameter
lookups.

Added a new test case to verify that nested types that mix
generics and non-generics in different ways consistently identify
the correct generic argument labels.
The new logic no longer includes non-generic parent types as part
of the type reference.

This also combines the 32- and 64-bit tests validations, since they
were identical for this test anyway.
The recursive structure made it a little awkward to correctly
distinguish between the root node (which has to be included
regardless of whether it has direct generic params)
and the parent nodes (which must only be included if they
have direct params).

So I rewrote this to do a simple two-pass iteration:
* The first pass walks the parent list collecting candidates
* The second pass walks the list backwards, assigning generic params

We then just stack the start node onto the end of the
list regardless of whether it has generic params.
Handle the top node directly in `createBoundGenericType`
so that we can be sure to always include it regardless
of whether it has direct generic type params or not.

The helper function can now focus only on handling
parents (where we must only include ones that actually
contain generic type params).  This separates the two
different cases and makes it a little easier to follow.

I refactored `reconstructParentsOfBoundGenericType` to
be iterative rather than recursive, though I'm not sure that
really matters.
@tbkka tbkka requested a review from a team as a code owner April 29, 2023 01:00
@tbkka
Copy link
Contributor Author

tbkka commented Apr 29, 2023

@swift-ci Please test

@tbkka tbkka merged commit 7ed6181 into swiftlang:release/5.9 May 1, 2023
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 2023
@tbkka tbkka deleted the 5.9-tbkka-RemoteMirror-nested-generics branch August 1, 2024 16:37
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