Skip to content

[IDE] Inject Sendable conformance on public types only in getTopLevelDeclsForDisplay #65168

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
Apr 18, 2023

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 13, 2023

When getTopLevelDeclsForDisplay is called on an imported module, it may lists non-public decls. If we they try to inject the conformance on Sendable on internal types the compiler may crash on failing to deserialize internal details. Let's only inject the conformance on public or package types to avoid this.

In the future we may want to make getTopLevelDeclsForDisplay return only public and package types and no internal details at all.

rdar://95430471

@xymus
Copy link
Contributor Author

xymus commented Apr 13, 2023

@swift-ci Please smoke test

@@ -55,6 +55,8 @@
// NO-FIXMES-NOT: FIXME
// RUN: %target-swift-ide-test -print-module-groups -module-to-print=Swift -source-filename %s -print-interface > %t-group.txt
// RUN: %FileCheck -check-prefix=CHECK-GROUPS1 %s < %t-group.txt
// RUN: %target-swift-ide-test -print-module-groups -module-to-print=Swift -source-filename %s -print-interface -enable-deserialization-safety > %t-group.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was crashing before with deserialization safety enabled? I wonder if we could craft an example that doesn't need it? Maybe not worth it though.

It just seems a little weird to have on this particular test, since it's somewhat surprising that enabling deserialization safety would have any impact here when we're just printing groups.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it crashed with deserialization safety enabled. Both -print-module-groups and -print-module call getTopLevelDeclsForDisplay, it looks like with the groups we also print the top-level decls in the group.

The failing scenario doesn't appear that complicated to reproduce but I didn't manage to write a reduced test case that triggers the crash. They're likely something to trigger in the requirement machine logic that I'm missing. Instead I've added a comment to the test.

@xymus
Copy link
Contributor Author

xymus commented Apr 14, 2023

/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/swift/lib/ASTGen/Sources/ASTGen/Macros.swift:549:57: error: value of type 'Syntax' has no member 'recursiveDescription'
    print("not on a macro expansion node: \(macroSyntax.recursiveDescription)")
                                            ~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~

@swift-ci Please smoke test macOS

When getTopLevelDeclsForDisplay is called on an imported module, it may
lists non-public decls. If we they try to inject the conformance on
Sendable on internal types, the compiler may crash on failing to
deserialize internal details. As a fix, let's only inject the
conformance on public or package types.

rdar://95430471
@xymus xymus force-pushed the display-public-only branch from 3a11a52 to 7f32a9e Compare April 14, 2023 20:40
@xymus
Copy link
Contributor Author

xymus commented Apr 14, 2023

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Apr 17, 2023

@swift-ci Please smoke test Windows

@xymus xymus merged commit 1ddc793 into swiftlang:main Apr 18, 2023
@xymus xymus deleted the display-public-only branch April 18, 2023 00:36
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