Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

IRGen: Narrow fix for type equivalence problem in searchNominalTypeMetadata()#85356

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
slavapestov wants to merge1 commit intoswiftlang:main
base:main
Choose a base branch
Loading
fromslavapestov:fix-rdar160649141

Conversation

@slavapestov
Copy link
Contributor

This fixes a regression introduced bye3c8f42, but the root cause was actually a subtle invariant violation in IRGen.

FulfillmentMap's use of canonical types as keys assumes that canonical type equality is sufficient for checking if two types "are the same". However, this is not true when those types contain type parameters, because two distinct type parameters might belong to the same equivalence class.

Thus, when we take the type's context substitution map, and apply it to each type parameter in our given list of requirements, the substitution operation could output a different but equivalent type parameter.

However, it turns out that in practice, we only end up here with a type that is either fully substituted, or is exactly the declared interface type of their nominal.

In the latter case, the type's substitution map is the identity substitution map, so we can just detect this case and skip the call to subst(). This avoids the problem.

I added an assertion that will fire if this assumption is ever violated in the future. To support the general case, we will need to pass down a generic signature that describes the type parameters that appear in the given type, and use this signature to reduce the type of each lookup key before we proceed.

Fixes rdar://160649141.

…tadata()This fixes a regression introduced bye3c8f42,but the root cause was actually a subtle invariant violationin IRGen.FulfillmentMap's use of canonical types as keys assumes thatcanonical type equality is sufficient for checking if two types"are the same". However, this is not true when those typescontain type parameters, because two distinct type parametersmight belong to the same equivalence class.Thus, when we take the type's context substitution map, andapply it to each type parameter in our given list ofrequirements, the substitution operation could output adifferent but equivalent type parameter.However, it turns out that in practice, we only end up herewith a type that is either fully substituted, or is exactlythe declared interface type of their nominal.In the latter case, the type's substitution map is theidentity substitution map, so we can just detect this case andskip the call to subst(). This avoids the problem.I added an assertion that will fire if this assumption is everviolated in the future. To support the general case, we willneed to pass down a generic signature that describes thetype parameters that appear in the given type, and use thissignature to reduce the type of each lookup key before weproceed.Fixes rdar://160649141.
@slavapestov
Copy link
ContributorAuthor

@aschwaighofer@rjmccall This fixes the provided test case, but some validation tests now fail because it is in fact not true that the type we get here is always either fully substituted or the declared interface type. So this needs a real fix where we either pass down the right generic signature for reduction, or we map the type into the right generic environment so that we can then doASSERT(!type->hasTypeParameter()) here.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@AnthonyLatsisAnthonyLatsisAwaiting requested review from AnthonyLatsisAnthonyLatsis is a code owner

@rjmccallrjmccallAwaiting requested review from rjmccallrjmccall is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@slavapestov

[8]ページ先頭

©2009-2025 Movatter.jp