Skip to content

[4.1] Associated type fixes for extraneous recursion, crashes, inference failure #14159

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

Conversation

DougGregor
Copy link
Member

Explanation: Associated type inference regressed quite a bit in 4.1, crashing more often (particularly when dealing with recursive constraints as in the Collection protocols) and failing to infer in some cases where 4.0 successfully inferred associated types. This pull request addresses a number of these issues.
Scope of Issue: Affects associated type inference is used whenever a conformance to a protocol with associated types is type-checked. We've seen a number of reports of regressions here.
Origination: Recursive protocol conformances, conditional conformances, and the reshuffling of the standard library protocols uncovered existing problems with associated type inference.
Risk: Low-ish risk; the change is breaking recursion that could go infinite, and allowing associated type inference to succeed in a few more cases, so it shouldn't cause more regressions.
Reviewed By: @xedin
Testing: Compiler regression tests, including new tests for each of the bugs addressed, and building known-affected open-source projects (e.g., Bond).
Radar / SR: SR-6609 / rdar://problem/36038033, rdar://problem/36453271, rdar://problem/16316115, SR-6746 / rdar://problem/36483751.

…tably.

There was a path through associated type inference where we would end
up recording a type witness that contained an error, but for which we
had not reported that error, which would lead to downstream
crashes. Make sure that we reject such inferences.

And because it triggers once we fix this issue... make sure break
recursion when trying to resolve type witnesses lazily.

Fixes the crash in SR-6609 / rdar://problem/36038033, but we're still
failing to infer in those cases.

(cherry picked from commit 24aa030)
…col extensions.

Typealiases in protocol extensions can be used to satisfy
associated type requirements. However, when they don’t meet all
of the requirements placed on the associated type, fall back to
the normal inference path rather than failing outright.

Fixes SR-6609 / rdar://problem/36038033.

(cherry picked from commit e471e40)
…ocol hierarchy.

As a minor step toward more global associated type inference,
allow tentative type witnesses to be found across a protocol
hierarchy, eliminating some recursion through associated type
inference. Fixes a recent regression in validation-test/stdlib/CollectionTypes.swift, as well as rdar://problem/36453271.

(cherry picked from commit 597c955)
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please nominate

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