AST: Change TypeAliasDecls to store an interface type as their underlying type

- TypeAliasDecl::getAliasType() is gone. Now, getDeclaredInterfaceType()
  always returns the NameAliasType.

- NameAliasTypes now always desugar to the underlying type as an
  interface type.

- The NameAliasType of a generic type alias no longer desugars to an
  UnboundGenericType; call TypeAliasDecl::getUnboundGenericType() if you
  want that.

- The "lazy mapTypeOutOfContext()" hack for deserialized TypeAliasDecls
  is gone.

- The process of constructing a synthesized TypeAliasDecl is much simpler
  now; instead of calling computeType(), setInterfaceType() and then
  setting the recursive properties in the right order, just call
  setUnderlyingType(), passing it either an interface type or a
  contextual type.

  In particular, many places weren't setting the recursive properties,
  such as the ClangImporter and deserialization. This meant that queries
  such as hasArchetype() or hasTypeParameter() would return incorrect
  results on NameAliasTypes, which caused various subtle problems.

- Finally, add some more tests for generic typealiases, most of which
  fail because they're still pretty broken.
This commit is contained in:
Slava Pestov
2016-12-15 01:53:41 -08:00
parent 757f253a3b
commit 2c6b9f71b6
39 changed files with 392 additions and 285 deletions

View File

@@ -477,11 +477,11 @@ static void reportRelated(ASTContext &Ctx,
} else if (auto *TAD = dyn_cast<TypeAliasDecl>(D)) {
// If underlying type exists, report the inheritance and conformance of the
// underlying type.
auto Ty = TAD->getUnderlyingType();
if (Ty) {
if (auto NM = Ty->getCanonicalType()->getAnyNominal()) {
if (TAD->hasInterfaceType()) {
// If underlying type exists, report the inheritance and conformance of the
// underlying type.
auto Ty = TAD->getDeclaredInterfaceType();
if (auto NM = Ty->getAnyNominal()) {
passInherits(NM->getInherited(), Consumer);
passConforms(NM->getSatisfiedProtocolRequirements(/*Sorted=*/true),
Consumer);