Skip to content

IDE: Remove bogus use of getCanonicalTypeInContext() #38359

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

slavapestov
Copy link
Contributor

The GenericSig might come from a protocol extension.

The original types in the Requirement come from this generic signature.

However, the Requirement can then be substituted with the base type's
concrete substitutions, and if the base type is a conforming nominal
type, we now have a Requirement whose types are written in terms of
the conforming nominal type's generic signature.

Therefore, the call to getCanonicalTypeInContext() might not produce
correct results, since there's no guarantee the protocol extension's
GenericSignature has the same requirements as the conforming type's.

This used to just silently produce incorrect results, but now asserts
when the RequirementMachine is enabled.

To fix this I replaced these calls with plain old getCanonicalType()
that does not take a GenericSignature.

If we find a case that is now broken as a result of this change, we'll
need to re-introduce some bookkeeping here to keep track of which
GenericSignature generates the types in the substituted Requirement.

The GenericSig might come from a protocol extension.

The original types in the Requirement come from this generic signature.

However, the Requirement can then be substituted with the base type's
concrete substitutions, and if the base type is a conforming nominal
type, we now have a Requirement whose types are written in terms of
the conforming nominal type's generic signature.

Therefore, the call to getCanonicalTypeInContext() might not produce
correct results, since there's no guarantee the protocol extension's
GenericSignature has the same requirements as the conforming type's.

This used to just silently produce incorrect results, but now asserts
when the RequirementMachine is enabled.

To fix this I replaced these calls with plain old getCanonicalType()
that does not take a GenericSignature.

If we find a case that is now broken as a result of this change, we'll
need to re-introduce some bookkeeping here to keep track of *which*
GenericSignature generates the types in the substituted Requirement.
@slavapestov slavapestov requested a review from rintaro July 13, 2021 03:09
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 81e265f into swiftlang:main Jul 13, 2021
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