Skip to content

[AST] Bring BoundNameAliastype up to parity with NameAliasType #15499

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

Closed

Conversation

DougGregor
Copy link
Member

Fix a number of small issues with BoundNameAliasType to bring it up to parity with NameAliasType, so the former will be able to replace the latter. This includes:

  • Making BoundNameAliasTypes profiling (for FoldingSet) and formation more robust against ill-formed ASTs
  • Not recording module types or existential parent types in the AST, because serialization cannot handle the former and the latter shouldn't be well-formed at all anyway
  • Adding lots of redundant logic so that we handle a BoundNameAliasType everywhere that we handle a NameAliasType, including for special cases where we currently always get a NameAliasType. This part is pure staging.

Serialization can’t handle them, and I’m not up for fixing it just yet.
This doesn't have a specific effect now, because all of these places
are likely to only see NameAliasType, but it is refactoring with the
intent of eliminating NameAliasType entirely.
With the exception of “has type variable”, which affects the arena used
for storage of a BoundNameAliasType, only propagate recursive properties
from the underlying type to a BoundNameAliasType, because the other
properties (e.g., “has archetype” or “has type parameter”) pulled from
syntactic sugar don’t apply.
When we’re performing type transformations involving types with type
parameters or archetypes, drop the sugar rather than performing
potentially-harmful transformations on it.
We currently accept code that refers to `ProtocolName.TypeName` when
`TypeName` is a typealias whose underlying type doesn’t refer to any
type parameters, which is awful. We should ban it, but until we do…
don’t represent the protocol in sugar or form substitutions, because they
won’t work.
The generic signature used to perform substitutions for a BoundNameAliasType
in ill-formed code might not line up with the generic signature in the
typealias. Separately record the signature we used to build the
BoundNameAliasType to make the AST more robust against such issues.

And, of course, we should always profile all of the fields, lest we
run into odd unintentional collisions.
@DougGregor
Copy link
Member Author

This pull request contains everything from #15497 except flipping the final switch over to BoundNameAliasType.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

Prior source-compatibility test with all of these changes passed, but... better safe than sorry.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test macOS

@DougGregor
Copy link
Member Author

The LLDB failure might be because LLDB doesn't know anything about BoundNameAliasType.

@DougGregor
Copy link
Member Author

Closing this out; all of these commits are part of #15497, which avoids the LLDB issue by eventually renaming BoundNameAliasType back to NameAliasType.

@DougGregor DougGregor closed this Mar 26, 2018
@DougGregor DougGregor deleted the finish-bound-name-alias branch March 26, 2018 05:52
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