Sema: Fix requirement/witness disambiguation for subclass existentials [4.0] #11242
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: If an imported Objective-C class
C
conforms to an Objective-C protocolQ
with a requirementfoo()
, a member lookup offoo
on a value of typeC & P
(whereP
is some unrelated protocol) would be incorrectly reported as ambiguous. This fixes the disambiguation logic that is used for such lookups on a concrete typeC
to also work for a subclass existentialC & P
.Scope of the issue: This is a bug in a new feature, but in Swift 4.0 mode, we started importing Objective-C types like
C <P> *
as subclass existentialsC & P
, whereas previously we would import them as an existential typeP
, so code examples that worked in Swift 3.2 mode can now fail to type check.Risk: Name lookup is a very tricky piece of code; hopefully the standard library, test suite and source compatibility test suite give us enough coverage here. I deliberately kept this patch for swift-4.0-branch as small as possible; there are other cleanups on master that hopefully make the logic here easier to follow and review.
Reviewed by: @DougGregor
Radar: rdar://problem/33291112.