Fix a couple of silly problems with extensions [4.0] #10443
Merged
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: A constrained extension of a typealias would result in a crash. Also, there was an old limitation that prevented us from being able to define a protocol extension with a typealias in the same module, probably as a workaround for some related problem, but it doesn't seem like this restriction is necessary anymore. Note that the crash I fixed occurs regardless of the module that the type is defined in, so maybe the restriction was bogus to begin with.
Origination: The crash was first reported against Swift 2 so this is an old problem. The related restriction has been there even longer.
Scope of the issue: Probably extensions of typealiases is not something people do intentionally very often, but happens when we rename a type and add a typealias for the old name.
Risk: Very low, we already desugar the type on this code path so we know this succeeds. Lifting the restriction might make some code that used to diagnose crash, but from my understanding of how extensions and name lookup works in today's Swift this doesn't seem likely. I strongly suspect it is vestigial, but @DougGregor can confirm.
Tested: New test case added, existing test for extension of protocol via typealias updated to reflect that it no longer produces a diagnostic.
Reviewed by: @DougGregor
Radar: rdar://problem/21607421