Skip to content

[6.0] Runtime: Fix runtime type resolution when mangled names refer to protocol extensions with Self same type constraints. #74999

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

jckarter
Copy link
Contributor

@jckarter jckarter commented Jul 5, 2024

Explanation: Fixes a bug with the runtime decoding mangled names referring to contexts inside of protocol extensions of the form protocol P where Self == Nominal.
Scope: Bug fix.
Issue: rdar://130168101
Original PR: #74997
Risk: Low. Fixes an edge case bug in a way that should have minimal impact on code outside of the edge case.
Testing: Swift CI, test case from bug report
Reviewer: @al45tair

@jckarter jckarter requested a review from a team as a code owner July 5, 2024 20:27
@jckarter
Copy link
Contributor Author

jckarter commented Jul 5, 2024

@swift-ci Please test

…ocol extensions with Self same type constraints.

If a type or opaque type descriptor appears inside of a protocol extension of the form:

```
extension P where Self == Nominal { ... }
```

then the runtime representation of the extension context was interpreted by the runtime
demangler as a nominal type extension, even though the parameterization is on the
`<Self>` generic signature of the protocol extension and not the generic signature of
the nominal type. This would cause spurious rejection of mangled names referencing the
extension context because we mistakenly thought that the type arguments mismatched with
the nominal type signature rather than matching them to the extension context.

Add some code to `_findExtendedTypeContextDescriptor` to detect when an extension is
a protocol extension with a `Self == SameType` constraint, and pass the extension along
rather than treating it as a nominal type extension. Fixes rdar://130168101.
@jckarter jckarter force-pushed the protocol-extension-self-same-type-runtime-resolution-6.0 branch from d35c9a7 to d519d44 Compare July 8, 2024 14:43
@jckarter
Copy link
Contributor Author

jckarter commented Jul 8, 2024

@swift-ci Please test

@jckarter jckarter merged commit 69ec03c into swiftlang:release/6.0 Jul 8, 2024
5 checks passed
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