Skip to content

[5.4][Deserialization] Fix error when typealias required by protocol refers to type in @_implementationOnly module #37490

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 1 commit into from
May 19, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 18, 2021

Cherry-picks #37011 to release/5.4.

  • Explanation: If a typealias refers to a type defined in a module which is imported as @_implementationOnly, deserialization fails (crashes). If LangOpts.EnableDeserializationRecovery is set to true (e.g. in SourceKit), we should recover from such failures more graceful and resolve unknown type as an ErrorType.

  • Scope: Modules that previously failed to deserialize

  • Risk: Low (we were previously crashing in all cases that exhibit new behavior)

  • Testing: Added test case to the test suite

  • Issue: rdar://78035645

  • Reviewer: Argyrios Kyrtzidis (@akyrtzi), Alexis Laferriere (@xymus)

…s to type in @_implementationOnly module

In the added test case, the `typealias` refers to the `HiddenStruct` type in the private module, which is imported as `@_implementationOnly`. Because the import is `@_implementationOnly`, during deserialization, we don’t import the private module and hence any reference to the `HiddenStruct` type fails. In the common deserialization code path, this causes us to skip over the `typealias` member. However, when creating the protocol conformance, we assume that we can resolve the type to which the `typealias` refers and thus we are crashing.

If `LangOpts.EnableDeserializationRecovery` is set to `true`, we should do our best to recover from such failures so this patch makes the deserialization failure handling more graceful and resolve the right-hand side of the `typealias` as an `ErrorType`.

Fixes rdar://72891807
@ahoppen ahoppen added the r5.4 label May 18, 2021
@ahoppen ahoppen requested a review from akyrtzi May 18, 2021 20:25
@ahoppen
Copy link
Member Author

ahoppen commented May 18, 2021

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented May 18, 2021

@swift-ci Please nominate

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3722969

@ahoppen
Copy link
Member Author

ahoppen commented May 19, 2021

@swift-ci Please test Linux

@ahoppen ahoppen merged commit 275278e into swiftlang:release/5.4 May 19, 2021
@ahoppen ahoppen deleted the pr-5.4/rdar-78035645 branch May 19, 2021 19:39
@AnthonyLatsis AnthonyLatsis added swift 5.4 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
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