Skip to content

[5.1] [runtime] Handle same-type constraints when resolving generic params #26032

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 3 commits into from
Jul 10, 2019

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Jul 9, 2019

Explanation: Swift uses mangled names to encode references to types that can be resolved at run time. However, the runtime support for this wasn't doing so correctly when a nested generic context makes one of an outer context's generic parameters redundant with a same-type constraint. This patch fixes two ways in which that logic was incorrect: it wasn't following extensions back to the original type, and it wasn't looking at the innermost context to see if a type was redundant.

Scope: Affects how the runtime resolves generic parameters when referenced from the metadata of generic types.

Issue: rdar://problem/52364601

Risk: Medium. The scope is pretty broad here, even if working code shouldn't change behavior in practice. It's possible that an existing app is encountering this bug today but coincidentally "working" based on incorrect information, and that app could change behavior.

Testing: Added compiler regression tests.

Reviewed by: @jckarter, @DougGregor

mikeash and others added 3 commits July 9, 2019 13:45
Harmless in practice, but still good hygiene.

(cherry picked from commit 57a0c9f)
[runtime] Handle same-type constraints when resolving generic params

rdar://problem/52364601
(cherry picked from commit 659c497)
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

Note: I have further tests to run on other parts of the runtime, but I wanted to get this part in now.

@swift-ci Please nominate

@shahmishal shahmishal merged commit b6daa93 into swiftlang:swift-5.1-branch Jul 10, 2019
@jrose-apple jrose-apple deleted the 5.1-same-gamgee branch July 10, 2019 02:23
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.

3 participants