[4.1][ConstraintSystem] Bind Self to correct contextual type for nested types in protocol #14161
+75
−1
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.
• Explanation: If something that we are trying to contextually bind is a nested type inside
protocol or protocol extension, let's try to find the innermost conforming type
from the current declaration context and map Self parameter of the protocol
to that nominal type. Since nested types in protocols aren't yet implemented this
is going to result in failure, but that's better than crashing.
• Scope of Issue: Affects constraint generation when trying to infer types for expressions which contain nested types in protocol or protocol extension context.
• Origination: Nested types in protocol or protocol extension context are not yet fully supported as a feature, but constraint solver shouldn't crash regardless.
• Risk: Low risk; Fixes a crash in the code which wouldn't type-check.
• Reviewed By: @DougGregor
• Testing: Compiler regression tests
• Radar / SR: rdar://problem/36449760.