Skip to content
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

IRGen: metadata for noncopyable exist. metatype #75989

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

kavon
Copy link
Member

@kavon kavon commented Aug 20, 2024

Missed a case when determining the strategy to use for obtaining the metadata for a noncopyable existential metatype. Without this patch, trying to use a metatype like any ~Copyable.Type can cause a crash at runtime when setting a deployment target that predates Swift 6.0, due to that runtime not knowing how to demangle inverses.

resolves rdar://134280902

@kavon kavon requested a review from rjmccall as a code owner August 20, 2024 18:59
@kavon
Copy link
Member Author

kavon commented Aug 20, 2024

@swift-ci smoke test

@kavon
Copy link
Member Author

kavon commented Aug 20, 2024

@swift-ci please test macOS platform

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

I'm a little surprised this is represented as a ProtocolCompositionType; should we just be looking for existential types in general?

I assume the only reason this is specific to existential metatypes is that we don't currently allow non-copyable existential types in Swift?

Missed a case when determining the strategy to use for obtaining the
metadata for a noncopyable existential metatype. Without this patch,
trying to use a metatype like `any ~Copyable.Type` can cause a crash at
runtime when setting a deployment target that predates Swift 6.0, due to
that runtime not knowing how to demangle inverses.

resolves rdar://134280902
@kavon
Copy link
Member Author

kavon commented Aug 21, 2024

@rjmccall We use to map InverseTypeRepr to a full-fledged InverseType, but we ended up changing the representation so that ~Copyable is just an empty ProtocolCompositionType with an "inverse Copyable bit" set.

So, this change in GenReflection covers any type we want to get-by-mangled-name that contains an inverse. I don't know off-hand what uses of existentials will trigger getTypeRef but I can try to add test coverage for those too, since we do have noncopyable existentials.

@kavon kavon force-pushed the reflection-fix-existentials branch from 35b25d3 to cd09269 Compare August 21, 2024 17:03
@kavon
Copy link
Member Author

kavon commented Aug 21, 2024

@swift-ci smoke test

@rjmccall
Copy link
Contributor

Alright, that sounds fine to me.

@kavon kavon enabled auto-merge August 21, 2024 21:51
@kavon kavon merged commit afe1fa0 into swiftlang:main Aug 22, 2024
2 of 3 checks passed
@kavon kavon deleted the reflection-fix-existentials branch August 23, 2024 19:57
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.

None yet

2 participants