Skip to content

Sema: Fix existential-metatype-to-Any conversion #72762

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 4 commits into from
Apr 2, 2024

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Apr 2, 2024

We were incorrectly unwrapping too many levels of metatype, and our ErasureExpr would end up with conformances for the instance type and not the metatype itself.

In the old universe, this was not a problem, but now Any has two protocol conformance members, so suddently this violated invariants.

I added a SILCloner test case that triggers the issue in the same way that it was originally observed, however subsequent commits in the PR add stronger assertions and with those assertions in place a bunch of tests failed already.

This was a regression, introduced in 6027bf4.

Fixes rdar://125460667.

We were incorrectly unwrapping too many levels of metatype, and
our ErasureExpr would end up with conformances for the instance
type and not the metatype itself.

In the old universe, this was not a problem, but now Any has two
protocol conformance members, so suddently this violated invariants.

This was a regression, introduced in 6027bf4.

Fixes rdar://125460667.
@slavapestov slavapestov requested review from hborla and xedin as code owners April 2, 2024 03:05
When erasing a pseudogeneric value in SILGen, we actually treat
the value as if it had the type `any AnyObject`, while in Sema,
it's an archetype. This requires SILGen to look up conformances
again instead of using the ones in the ErasureExpr.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

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