Skip to content

Commit 81c5a67

Browse files
authored
Merge pull request #21758 from pschuh/s-1
Rename NameAliasType to TypeAliasType.
2 parents 5cc751c + f5859ff commit 81c5a67

39 files changed

+103
-103
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ struct PrintOptions {
335335
/// formatting.
336336
bool PrintOriginalSourceText = false;
337337

338-
/// When printing a name alias type, whether print the underlying type instead
338+
/// When printing a type alias type, whether print the underlying type instead
339339
/// of the alias.
340-
bool PrintNameAliasUnderlyingType = false;
340+
bool PrintTypeAliasUnderlyingType = false;
341341

342342
/// When printing an Optional<T>, rather than printing 'T?', print
343343
/// 'T!'. Used as a modifier only when we know we're printing

include/swift/AST/TypeNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ TYPE(InOut, Type)
153153
UNCHECKED_TYPE(TypeVariable, Type)
154154
ABSTRACT_SUGARED_TYPE(Sugar, Type)
155155
SUGARED_TYPE(Paren, SugarType)
156-
SUGARED_TYPE(NameAlias, SugarType)
156+
SUGARED_TYPE(TypeAlias, SugarType)
157157
ABSTRACT_SUGARED_TYPE(SyntaxSugar, SugarType)
158158
ABSTRACT_SUGARED_TYPE(UnarySyntaxSugar, SyntaxSugarType)
159159
SUGARED_TYPE(ArraySlice, UnarySyntaxSugarType)

include/swift/AST/Types.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
380380
GenericArgCount : 32
381381
);
382382

383-
SWIFT_INLINE_BITFIELD_FULL(NameAliasType, SugarType, 1+1,
383+
SWIFT_INLINE_BITFIELD_FULL(TypeAliasType, SugarType, 1+1,
384384
: NumPadBits,
385385

386386
/// Whether we have a parent type.
@@ -1634,25 +1634,25 @@ class SugarType : public TypeBase {
16341634

16351635
/// A reference to a type alias that is somehow generic, along with the
16361636
/// set of substitutions to apply to make the type concrete.
1637-
class NameAliasType final
1637+
class TypeAliasType final
16381638
: public SugarType, public llvm::FoldingSetNode,
1639-
llvm::TrailingObjects<NameAliasType, Type, SubstitutionMap>
1639+
llvm::TrailingObjects<TypeAliasType, Type, SubstitutionMap>
16401640
{
16411641
TypeAliasDecl *typealias;
16421642

16431643
friend class ASTContext;
16441644
friend TrailingObjects;
16451645

1646-
NameAliasType(TypeAliasDecl *typealias, Type parent,
1646+
TypeAliasType(TypeAliasDecl *typealias, Type parent,
16471647
SubstitutionMap substitutions, Type underlying,
16481648
RecursiveTypeProperties properties);
16491649

16501650
size_t numTrailingObjects(OverloadToken<Type>) const {
1651-
return Bits.NameAliasType.HasParent ? 1 : 0;
1651+
return Bits.TypeAliasType.HasParent ? 1 : 0;
16521652
}
16531653

16541654
size_t numTrailingObjects(OverloadToken<SubstitutionMap>) const {
1655-
return Bits.NameAliasType.HasSubstitutionMap ? 1 : 0;
1655+
return Bits.TypeAliasType.HasSubstitutionMap ? 1 : 0;
16561656
}
16571657

16581658
public:
@@ -1661,7 +1661,7 @@ class NameAliasType final
16611661
return getSubstitutionMap().getGenericSignature();
16621662
}
16631663

1664-
static NameAliasType *get(TypeAliasDecl *typealias, Type parent,
1664+
static TypeAliasType *get(TypeAliasDecl *typealias, Type parent,
16651665
SubstitutionMap substitutions, Type underlying);
16661666

16671667
/// Returns the declaration that declares this type.
@@ -1673,14 +1673,14 @@ class NameAliasType final
16731673
/// Retrieve the parent of this type as written, e.g., the part that was
16741674
/// written before ".", if provided.
16751675
Type getParent() const {
1676-
return Bits.NameAliasType.HasParent ? *getTrailingObjects<Type>()
1676+
return Bits.TypeAliasType.HasParent ? *getTrailingObjects<Type>()
16771677
: Type();
16781678
}
16791679

16801680
/// Retrieve the substitution map applied to the declaration's underlying
16811681
/// to produce the described type.
16821682
SubstitutionMap getSubstitutionMap() const {
1683-
if (!Bits.NameAliasType.HasSubstitutionMap)
1683+
if (!Bits.TypeAliasType.HasSubstitutionMap)
16841684
return SubstitutionMap();
16851685

16861686
return *getTrailingObjects<SubstitutionMap>();
@@ -1703,7 +1703,7 @@ class NameAliasType final
17031703

17041704
// Implement isa/cast/dyncast/etc.
17051705
static bool classof(const TypeBase *T) {
1706-
return T->getKind() == TypeKind::NameAlias;
1706+
return T->getKind() == TypeKind::TypeAlias;
17071707
}
17081708
};
17091709

include/swift/IDE/CodeCompletion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class CodeCompletionStringChunk {
133133
/// Required parameter type.
134134
CallParameterType,
135135
/// Desugared closure parameter type. This can be used to get the
136-
/// closure type if CallParameterType is a NameAliasType.
136+
/// closure type if CallParameterType is a TypeAliasType.
137137
CallParameterClosureType,
138138

139139
/// A placeholder for \c ! or \c ? in a call to a method found by dynamic

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ namespace decls_block {
693693
TypeIDField // canonical type (a fallback)
694694
>;
695695

696-
using NameAliasTypeLayout = BCRecordLayout<
696+
using TypeAliasTypeLayout = BCRecordLayout<
697697
NAME_ALIAS_TYPE,
698698
DeclIDField, // typealias decl
699699
TypeIDField, // parent type

lib/AST/ASTContext.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
294294
/// arenas.
295295
struct Arena {
296296
llvm::DenseMap<Type, ErrorType *> ErrorTypesWithOriginal;
297-
llvm::FoldingSet<NameAliasType> NameAliasTypes;
297+
llvm::FoldingSet<TypeAliasType> TypeAliasTypes;
298298
llvm::FoldingSet<TupleType> TupleTypes;
299299
llvm::DenseMap<std::pair<Type,char>, MetatypeType*> MetatypeTypes;
300300
llvm::DenseMap<std::pair<Type,char>,
@@ -2909,30 +2909,30 @@ StringRef ASTContext::getSwiftName(KnownFoundationEntity kind) {
29092909
// Type manipulation routines.
29102910
//===----------------------------------------------------------------------===//
29112911

2912-
NameAliasType::NameAliasType(TypeAliasDecl *typealias, Type parent,
2912+
TypeAliasType::TypeAliasType(TypeAliasDecl *typealias, Type parent,
29132913
SubstitutionMap substitutions,
29142914
Type underlying,
29152915
RecursiveTypeProperties properties)
2916-
: SugarType(TypeKind::NameAlias, underlying, properties),
2916+
: SugarType(TypeKind::TypeAlias, underlying, properties),
29172917
typealias(typealias) {
29182918
// Record the parent (or absence of a parent).
29192919
if (parent) {
2920-
Bits.NameAliasType.HasParent = true;
2920+
Bits.TypeAliasType.HasParent = true;
29212921
*getTrailingObjects<Type>() = parent;
29222922
} else {
2923-
Bits.NameAliasType.HasParent = false;
2923+
Bits.TypeAliasType.HasParent = false;
29242924
}
29252925

29262926
// Record the substitutions.
29272927
if (substitutions) {
2928-
Bits.NameAliasType.HasSubstitutionMap = true;
2928+
Bits.TypeAliasType.HasSubstitutionMap = true;
29292929
*getTrailingObjects<SubstitutionMap>() = substitutions;
29302930
} else {
2931-
Bits.NameAliasType.HasSubstitutionMap = false;
2931+
Bits.TypeAliasType.HasSubstitutionMap = false;
29322932
}
29332933
}
29342934

2935-
NameAliasType *NameAliasType::get(TypeAliasDecl *typealias, Type parent,
2935+
TypeAliasType *TypeAliasType::get(TypeAliasDecl *typealias, Type parent,
29362936
SubstitutionMap substitutions,
29372937
Type underlying) {
29382938
// Compute the recursive properties.
@@ -2960,30 +2960,30 @@ NameAliasType *NameAliasType::get(TypeAliasDecl *typealias, Type parent,
29602960

29612961
// Profile the type.
29622962
llvm::FoldingSetNodeID id;
2963-
NameAliasType::Profile(id, typealias, parent, substitutions, underlying);
2963+
TypeAliasType::Profile(id, typealias, parent, substitutions, underlying);
29642964

29652965
// Did we already record this type?
29662966
void *insertPos;
2967-
auto &types = ctx.getImpl().getArena(arena).NameAliasTypes;
2967+
auto &types = ctx.getImpl().getArena(arena).TypeAliasTypes;
29682968
if (auto result = types.FindNodeOrInsertPos(id, insertPos))
29692969
return result;
29702970

29712971
// Build a new type.
29722972
auto size = totalSizeToAlloc<Type, SubstitutionMap>(parent ? 1 : 0,
29732973
genericSig ? 1 : 0);
2974-
auto mem = ctx.Allocate(size, alignof(NameAliasType), arena);
2975-
auto result = new (mem) NameAliasType(typealias, parent, substitutions,
2974+
auto mem = ctx.Allocate(size, alignof(TypeAliasType), arena);
2975+
auto result = new (mem) TypeAliasType(typealias, parent, substitutions,
29762976
underlying, storedProperties);
29772977
types.InsertNode(result, insertPos);
29782978
return result;
29792979
}
29802980

2981-
void NameAliasType::Profile(llvm::FoldingSetNodeID &id) const {
2981+
void TypeAliasType::Profile(llvm::FoldingSetNodeID &id) const {
29822982
Profile(id, getDecl(), getParent(), getSubstitutionMap(),
29832983
Type(getSinglyDesugaredType()));
29842984
}
29852985

2986-
void NameAliasType::Profile(
2986+
void TypeAliasType::Profile(
29872987
llvm::FoldingSetNodeID &id,
29882988
TypeAliasDecl *typealias,
29892989
Type parent, SubstitutionMap substitutions,

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3227,8 +3227,8 @@ namespace {
32273227
PrintWithColorRAII(OS, ParenthesisColor) << ')';
32283228
}
32293229

3230-
void visitNameAliasType(NameAliasType *T, StringRef label) {
3231-
printCommon(label, "name_alias_type");
3230+
void visitTypeAliasType(TypeAliasType *T, StringRef label) {
3231+
printCommon(label, "type_alias_type");
32323232
printField("decl", T->getDecl()->printRef());
32333233
if (T->getParent())
32343234
printRec("parent", T->getParent());

lib/AST/ASTMangler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static bool shouldMangleAsGeneric(Type type) {
659659
if (!type)
660660
return false;
661661

662-
if (auto typeAlias = dyn_cast<NameAliasType>(type.getPointer()))
662+
if (auto typeAlias = dyn_cast<TypeAliasType>(type.getPointer()))
663663
return !typeAlias->getSubstitutionMap().empty();
664664

665665
return type->isSpecialized();
@@ -723,9 +723,9 @@ void ASTMangler::appendType(Type type) {
723723
appendType(cast<BuiltinVectorType>(tybase)->getElementType());
724724
return appendOperator("Bv",
725725
cast<BuiltinVectorType>(tybase)->getNumElements());
726-
case TypeKind::NameAlias: {
726+
case TypeKind::TypeAlias: {
727727
assert(DWARFMangling && "sugared types are only legal for the debugger");
728-
auto aliasTy = cast<NameAliasType>(tybase);
728+
auto aliasTy = cast<TypeAliasType>(tybase);
729729

730730
// It's not possible to mangle the context of the builtin module.
731731
// For the DWARF output we want to mangle the type alias + context,
@@ -834,7 +834,7 @@ void ASTMangler::appendType(Type type) {
834834
case TypeKind::BoundGenericEnum:
835835
case TypeKind::BoundGenericStruct: {
836836
GenericTypeDecl *Decl;
837-
if (auto typeAlias = dyn_cast<NameAliasType>(type.getPointer()))
837+
if (auto typeAlias = dyn_cast<TypeAliasType>(type.getPointer()))
838838
Decl = typeAlias->getDecl();
839839
else
840840
Decl = type->getAnyGeneric();
@@ -1075,7 +1075,7 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
10751075
void ASTMangler::appendBoundGenericArgs(Type type, bool &isFirstArgList) {
10761076
TypeBase *typePtr = type.getPointer();
10771077
ArrayRef<Type> genericArgs;
1078-
if (auto *typeAlias = dyn_cast<NameAliasType>(typePtr)) {
1078+
if (auto *typeAlias = dyn_cast<TypeAliasType>(typePtr)) {
10791079
appendBoundGenericArgs(typeAlias->getDecl(),
10801080
typeAlias->getSubstitutionMap(),
10811081
isFirstArgList);
@@ -1177,7 +1177,7 @@ void ASTMangler::appendRetroactiveConformances(Type type) {
11771177
// Dig out the substitution map to use.
11781178
SubstitutionMap subMap;
11791179
ModuleDecl *module;
1180-
if (auto typeAlias = dyn_cast<NameAliasType>(type.getPointer())) {
1180+
if (auto typeAlias = dyn_cast<TypeAliasType>(type.getPointer())) {
11811181
module = Mod ? Mod : typeAlias->getDecl()->getModuleContext();
11821182
subMap = typeAlias->getSubstitutionMap();
11831183
} else {

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static bool isPublicOrUsableFromInline(Type ty) {
7777
return !ty.findIf([](Type typePart) -> bool {
7878
// FIXME: If we have an internal typealias for a non-internal type, we ought
7979
// to be able to print it by desugaring.
80-
if (auto *aliasTy = dyn_cast<NameAliasType>(typePart.getPointer()))
80+
if (auto *aliasTy = dyn_cast<TypeAliasType>(typePart.getPointer()))
8181
return !isPublicOrUsableFromInline(aliasTy->getDecl());
8282
if (auto *nominal = typePart->getAnyNominal())
8383
return !isPublicOrUsableFromInline(nominal);
@@ -3452,8 +3452,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
34523452
Printer << BUILTIN_TYPE_NAME_SILTOKEN;
34533453
}
34543454

3455-
void visitNameAliasType(NameAliasType *T) {
3456-
if (Options.PrintForSIL || Options.PrintNameAliasUnderlyingType) {
3455+
void visitTypeAliasType(TypeAliasType *T) {
3456+
if (Options.PrintForSIL || Options.PrintTypeAliasUnderlyingType) {
34573457
visit(T->getSinglyDesugaredType());
34583458
return;
34593459
}
@@ -4472,7 +4472,7 @@ swift::getInheritedForPrinting(const Decl *decl,
44724472
for (auto TL: inherited) {
44734473
if (auto ty = TL.getType()) {
44744474
bool foundUnprintable = ty.findIf([shouldPrint](Type subTy) {
4475-
if (auto aliasTy = dyn_cast<NameAliasType>(subTy.getPointer()))
4475+
if (auto aliasTy = dyn_cast<TypeAliasType>(subTy.getPointer()))
44764476
return !shouldPrint(aliasTy->getDecl());
44774477
if (auto NTD = subTy->getAnyNominal())
44784478
return !shouldPrint(NTD);

lib/AST/AccessScopeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ TypeAccessScopeChecker::TypeAccessScopeChecker(const DeclContext *useDC,
6969
TypeWalker::Action
7070
TypeAccessScopeChecker::walkToTypePre(Type T) {
7171
ValueDecl *VD;
72-
if (auto *BNAD = dyn_cast<NameAliasType>(T.getPointer()))
72+
if (auto *BNAD = dyn_cast<TypeAliasType>(T.getPointer()))
7373
VD = BNAD->getDecl();
7474
else if (auto *NTD = T->getAnyNominal())
7575
VD = NTD;

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3245,7 +3245,7 @@ void TypeAliasDecl::setUnderlyingType(Type underlying) {
32453245
auto parentDC = getDeclContext();
32463246
if (parentDC->isTypeContext())
32473247
parent = parentDC->getDeclaredInterfaceType();
3248-
auto sugaredType = NameAliasType::get(this, parent, subs, underlying);
3248+
auto sugaredType = TypeAliasType::get(this, parent, subs, underlying);
32493249
setInterfaceType(MetatypeType::get(sugaredType, ctx));
32503250
}
32513251
}

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void formatSelectionArgument(StringRef ModifierArguments,
331331
static bool isInterestingTypealias(Type type) {
332332
// Dig out the typealias declaration, if there is one.
333333
TypeAliasDecl *aliasDecl = nullptr;
334-
if (auto aliasTy = dyn_cast<NameAliasType>(type.getPointer()))
334+
if (auto aliasTy = dyn_cast<TypeAliasType>(type.getPointer()))
335335
aliasDecl = aliasTy->getDecl();
336336
else
337337
return false;

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,7 +3856,7 @@ static Type substituteConcreteType(GenericSignatureBuilder &builder,
38563856

38573857
// If we had a typealias, form a sugared type.
38583858
if (typealias) {
3859-
type = NameAliasType::get(typealias, parentType, subMap, type);
3859+
type = TypeAliasType::get(typealias, parentType, subMap, type);
38603860
}
38613861

38623862
return type;
@@ -5315,13 +5315,13 @@ class GenericSignatureBuilder::InferRequirementsWalker : public TypeWalker {
53155315

53165316
Action walkToTypePost(Type ty) override {
53175317
// Infer from generic typealiases.
5318-
if (auto NameAlias = dyn_cast<NameAliasType>(ty.getPointer())) {
5319-
auto decl = NameAlias->getDecl();
5318+
if (auto TypeAlias = dyn_cast<TypeAliasType>(ty.getPointer())) {
5319+
auto decl = TypeAlias->getDecl();
53205320
auto genericSig = decl->getGenericSignature();
53215321
if (!genericSig)
53225322
return Action::Continue;
53235323

5324-
auto subMap = NameAlias->getSubstitutionMap();
5324+
auto subMap = TypeAlias->getSubstitutionMap();
53255325
for (const auto &rawReq : genericSig->getRequirements()) {
53265326
if (auto req = rawReq.subst(subMap))
53275327
Builder.addRequirement(*req, source, nullptr);

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ directReferencesForTypeRepr(Evaluator &evaluator,
25152515

25162516
static DirectlyReferencedTypeDecls directReferencesForType(Type type) {
25172517
// If it's a typealias, return that.
2518-
if (auto aliasType = dyn_cast<NameAliasType>(type.getPointer()))
2518+
if (auto aliasType = dyn_cast<TypeAliasType>(type.getPointer()))
25192519
return { 1, aliasType->getDecl() };
25202520

25212521
// If there is a generic declaration, return it.

lib/AST/PrettyStackTrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace {
169169
Decl *visitNominalType(NominalType *type) {
170170
return type->getDecl();
171171
}
172-
Decl *visitNameAliasType(NameAliasType *type) {
172+
Decl *visitTypeAliasType(TypeAliasType *type) {
173173
return type->getDecl();
174174
}
175175
};

0 commit comments

Comments
 (0)