Skip to content

Emit reflection metadata for noncopyable fields more often #72163

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

DougGregor
Copy link
Member

When emitting reflection metadata for fields that have noncopyable type with deployment targets that predate support for noncopyable types, we introduce some indirection to make sure that these fields are only visible to reflection clients (e.g., mirrors) when running on a sufficiently-new Swift runtime. However, this indirection has the downside that out-of-process clients (such as LLDB) can no longer reflect the fields.

Tweak the heuristic to only introduce the indirection if the field is guaranteed to have noncopyable type. If it somehow could be copyable, e.g., based on the properties of its generic arguments, then still emit the normal metadata. This eliminates regressions when existing generic types like Optional become conditionally Copyable (based on their Wrapped functions).

When emitting reflection metadata for fields that have noncopyable
type with deployment targets that predate support for noncopyable
types, we introduce some indirection to make sure that these fields
are only visible to reflection clients (e.g., mirrors) when running on
a sufficiently-new Swift runtime. However, this indirection has the
downside that out-of-process clients (such as LLDB) can no longer
reflect the fields.

Tweak the heuristic to only introduce the indirection if the field is
*guaranteed* to have noncopyable type. If it somehow could be
copyable, e.g., based on the properties of its generic arguments, then
still emit the normal metadata. This eliminates regressions when
existing generic types like Optional become conditionally Copyable
(based on their Wrapped functions).
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 0ef978a into swiftlang:main Mar 8, 2024
@DougGregor DougGregor deleted the noncopyable-field-reflection-heuristic branch March 8, 2024 04:32
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.

1 participant