Skip to content

Conversation

@slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jan 10, 2024

Cherry-pick of #70830

  • Description: Fixes a regression where associated type inference did not consider any witness whose type contains Self.Foo, where Foo is a member of a protocol (usually you can write Foo instead of Self.Foo, but the latter is more explicit). The correct behavior is that such witnesses should only be discarded if Foo is one of the associated types being inferred.

  • Scope of the issue: Anyone impacted would have to explicitly declare a type alias instead of letting the compiler infer it.

  • Origination: Regression from the second cherry-pick in Sema: Associated type inference fixes [5.10] #70696.

  • Radar: Fixes rdar://problem/120743365.

  • Tested: Reduced test case added from impacted project.

  • Risk: Sigh. Unfortunately this is the second follow-up PR fixing issues in the original change from November (Sema: Associated type inference skips witnesses that might trigger a request cycle [5.10] #69952), but I hope this particular change is safe since the new code path (ignoring a witness that "might cause a cycle") will now execute in strictly fewer situations than it did previously.

  • Reviewed by: @hborla

We don't want to throw out a witness if it has any mention of 'Self.Foo';
we must also check that 'Foo' is one of the associated types being
inferred. Otherwise, it may be a protocol type alias, in which case
we want to proceed with the witness.

This fixes a regression from a recent change, a576984.

Fixes rdar://problem/120743365.
@slavapestov slavapestov requested a review from a team as a code owner January 10, 2024 21:58
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@hborla hborla merged commit 6a90011 into swiftlang:release/5.10 Jan 11, 2024
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.

3 participants