mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user