Skip to content

[Runtime] Fixed shared cache protocol conformance lookup with subclasses. #36468

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

mikeash
Copy link
Contributor

@mikeash mikeash commented Mar 17, 2021

Match the logic used in the non-shared-cache case, where we walk up the class hierarchy to find the class where the conformance actually applies. This is important in cases like:

class Super : Proto {}
class Sub: Super {}

Looking up the conformance Sub: Proto without this logic causes it to attempt to find the witness table for Sub<Int>, which fails. The correct logic looks up the witness table for Super<Int>.

While we're in there, fix a bug in the shared cache validation code (std::find wasn't checked for failure correctly) and add a SWIFT_DEBUG_ENABLE_SHARED_CACHE_PROTOCOL_CONFORMANCES environment variable to allow us to turn the shared cache integration off at runtime.

rdar://75431771

…ses.

Match the logic used in the non-shared-cache case, where we walk up the class hierarchy to find the class where the conformance actually applies. This is important in cases like:

  class Super<T> : Proto {}
  class Sub: Super<Int> {}

Looking up the conformance `Sub: Proto` without this logic causes it to attempt to find the witness table for `Sub<Int>`, which fails. The correct logic looks up the witness table for `Super<Int>`.

While we're in there, fix a bug in the shared cache validation code (std::find wasn't checked for failure correctly) and add a `SWIFT_DEBUG_ENABLE_SHARED_CACHE_PROTOCOL_CONFORMANCES` environment variable to allow us to turn the shared cache integration off at runtime.

rdar://75431771
@mikeash mikeash requested review from cooperp and tbkka March 17, 2021 16:16
@mikeash
Copy link
Contributor Author

mikeash commented Mar 17, 2021

@swift-ci please test

@mikeash mikeash merged commit 15b83e1 into swiftlang:main Mar 17, 2021
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