Skip to content
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

[4.1] [GSB] Always ensure that we wire up typealiases in protocol extensions. #15014

Conversation

DougGregor
Copy link
Member

  • Explanation: Typealiases within protocol extensions have been used as a hack to achieve same-type constraints on associated types from inherited protocols since Swift 3(ish). Swift 4 brought where clauses for associated types and protocols, which eliminated the need for this hack, but some of this pattern still persists. When the associated type comes from an inherited protocol and the typealias is in a protocol extension, we would miss the same-type constraint (sometimes) and could crash in IR generation with no compiler diagnostics.
  • Scope: Type checking of generics. Potentially affects any project putting typealiases into protocol extensions, a command (although somewhat dated) pattern. In SR-7097, this showed up as a regression from 4.0 in a project that makes use of Vapor.
  • Risk: Medium-low. This establishes additional same-type constraints among same-named types. There are a few possible risks here: new warnings because this code is using older patterns (rather than proper language support for same-type constraints), new constraints that could break existing (incorrectly-accepted) code by properly diagnosing that code as wrong, or other failures due to, e.g., more name lookup along this path. More warnings are the most likely and also most benign; the other failure modes are speculative but possible.
  • Testing: Compiler regression tests, built the affected project
  • Reviewer: @slavapestov
  • Radar: SR-7097 / rdar://problem/38001269

During "expansion" of the requirements of a protocol, we check all of
the inherited associated types against definitions within the
protocol. Also look for concrete types within extensions of that
protocol, so we can identify more places where developers have used
typealiases in inheriting protocols to effect a same-type constraint
on an inherited associated type.

Fixes SR-7097 / rdar://problem/38001269.
@DougGregor DougGregor requested review from xedin and huonw and removed request for xedin and huonw March 6, 2018 06:24
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please nominate

@DougGregor DougGregor merged commit f452171 into apple:swift-4.1-branch Mar 6, 2018
@DougGregor DougGregor deleted the gsb-ext-typealias-inherited-assoc-sr-7097-4.1 branch March 6, 2018 22:02
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.

None yet

1 participant