Skip to content

Rename NameAliasType to TypeAliasType. #21758

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

Merged
merged 1 commit into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ struct PrintOptions {
/// formatting.
bool PrintOriginalSourceText = false;

/// When printing a name alias type, whether print the underlying type instead
/// When printing a type alias type, whether print the underlying type instead
/// of the alias.
bool PrintNameAliasUnderlyingType = false;
bool PrintTypeAliasUnderlyingType = false;

/// When printing an Optional<T>, rather than printing 'T?', print
/// 'T!'. Used as a modifier only when we know we're printing
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/TypeNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ TYPE(InOut, Type)
UNCHECKED_TYPE(TypeVariable, Type)
ABSTRACT_SUGARED_TYPE(Sugar, Type)
SUGARED_TYPE(Paren, SugarType)
SUGARED_TYPE(NameAlias, SugarType)
SUGARED_TYPE(TypeAlias, SugarType)
ABSTRACT_SUGARED_TYPE(SyntaxSugar, SugarType)
ABSTRACT_SUGARED_TYPE(UnarySyntaxSugar, SyntaxSugarType)
SUGARED_TYPE(ArraySlice, UnarySyntaxSugarType)
Expand Down
20 changes: 10 additions & 10 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
GenericArgCount : 32
);

SWIFT_INLINE_BITFIELD_FULL(NameAliasType, SugarType, 1+1,
SWIFT_INLINE_BITFIELD_FULL(TypeAliasType, SugarType, 1+1,
: NumPadBits,

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

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

friend class ASTContext;
friend TrailingObjects;

NameAliasType(TypeAliasDecl *typealias, Type parent,
TypeAliasType(TypeAliasDecl *typealias, Type parent,
SubstitutionMap substitutions, Type underlying,
RecursiveTypeProperties properties);

size_t numTrailingObjects(OverloadToken<Type>) const {
return Bits.NameAliasType.HasParent ? 1 : 0;
return Bits.TypeAliasType.HasParent ? 1 : 0;
}

size_t numTrailingObjects(OverloadToken<SubstitutionMap>) const {
return Bits.NameAliasType.HasSubstitutionMap ? 1 : 0;
return Bits.TypeAliasType.HasSubstitutionMap ? 1 : 0;
}

public:
Expand All @@ -1661,7 +1661,7 @@ class NameAliasType final
return getSubstitutionMap().getGenericSignature();
}

static NameAliasType *get(TypeAliasDecl *typealias, Type parent,
static TypeAliasType *get(TypeAliasDecl *typealias, Type parent,
SubstitutionMap substitutions, Type underlying);

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

/// Retrieve the substitution map applied to the declaration's underlying
/// to produce the described type.
SubstitutionMap getSubstitutionMap() const {
if (!Bits.NameAliasType.HasSubstitutionMap)
if (!Bits.TypeAliasType.HasSubstitutionMap)
return SubstitutionMap();

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

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

Expand Down
2 changes: 1 addition & 1 deletion include/swift/IDE/CodeCompletion.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class CodeCompletionStringChunk {
/// Required parameter type.
CallParameterType,
/// Desugared closure parameter type. This can be used to get the
/// closure type if CallParameterType is a NameAliasType.
/// closure type if CallParameterType is a TypeAliasType.
CallParameterClosureType,

/// A placeholder for \c ! or \c ? in a call to a method found by dynamic
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ namespace decls_block {
TypeIDField // canonical type (a fallback)
>;

using NameAliasTypeLayout = BCRecordLayout<
using TypeAliasTypeLayout = BCRecordLayout<
NAME_ALIAS_TYPE,
DeclIDField, // typealias decl
TypeIDField, // parent type
Expand Down
28 changes: 14 additions & 14 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
/// arenas.
struct Arena {
llvm::DenseMap<Type, ErrorType *> ErrorTypesWithOriginal;
llvm::FoldingSet<NameAliasType> NameAliasTypes;
llvm::FoldingSet<TypeAliasType> TypeAliasTypes;
llvm::FoldingSet<TupleType> TupleTypes;
llvm::DenseMap<std::pair<Type,char>, MetatypeType*> MetatypeTypes;
llvm::DenseMap<std::pair<Type,char>,
Expand Down Expand Up @@ -2909,30 +2909,30 @@ StringRef ASTContext::getSwiftName(KnownFoundationEntity kind) {
// Type manipulation routines.
//===----------------------------------------------------------------------===//

NameAliasType::NameAliasType(TypeAliasDecl *typealias, Type parent,
TypeAliasType::TypeAliasType(TypeAliasDecl *typealias, Type parent,
SubstitutionMap substitutions,
Type underlying,
RecursiveTypeProperties properties)
: SugarType(TypeKind::NameAlias, underlying, properties),
: SugarType(TypeKind::TypeAlias, underlying, properties),
typealias(typealias) {
// Record the parent (or absence of a parent).
if (parent) {
Bits.NameAliasType.HasParent = true;
Bits.TypeAliasType.HasParent = true;
*getTrailingObjects<Type>() = parent;
} else {
Bits.NameAliasType.HasParent = false;
Bits.TypeAliasType.HasParent = false;
}

// Record the substitutions.
if (substitutions) {
Bits.NameAliasType.HasSubstitutionMap = true;
Bits.TypeAliasType.HasSubstitutionMap = true;
*getTrailingObjects<SubstitutionMap>() = substitutions;
} else {
Bits.NameAliasType.HasSubstitutionMap = false;
Bits.TypeAliasType.HasSubstitutionMap = false;
}
}

NameAliasType *NameAliasType::get(TypeAliasDecl *typealias, Type parent,
TypeAliasType *TypeAliasType::get(TypeAliasDecl *typealias, Type parent,
SubstitutionMap substitutions,
Type underlying) {
// Compute the recursive properties.
Expand Down Expand Up @@ -2960,30 +2960,30 @@ NameAliasType *NameAliasType::get(TypeAliasDecl *typealias, Type parent,

// Profile the type.
llvm::FoldingSetNodeID id;
NameAliasType::Profile(id, typealias, parent, substitutions, underlying);
TypeAliasType::Profile(id, typealias, parent, substitutions, underlying);

// Did we already record this type?
void *insertPos;
auto &types = ctx.getImpl().getArena(arena).NameAliasTypes;
auto &types = ctx.getImpl().getArena(arena).TypeAliasTypes;
if (auto result = types.FindNodeOrInsertPos(id, insertPos))
return result;

// Build a new type.
auto size = totalSizeToAlloc<Type, SubstitutionMap>(parent ? 1 : 0,
genericSig ? 1 : 0);
auto mem = ctx.Allocate(size, alignof(NameAliasType), arena);
auto result = new (mem) NameAliasType(typealias, parent, substitutions,
auto mem = ctx.Allocate(size, alignof(TypeAliasType), arena);
auto result = new (mem) TypeAliasType(typealias, parent, substitutions,
underlying, storedProperties);
types.InsertNode(result, insertPos);
return result;
}

void NameAliasType::Profile(llvm::FoldingSetNodeID &id) const {
void TypeAliasType::Profile(llvm::FoldingSetNodeID &id) const {
Profile(id, getDecl(), getParent(), getSubstitutionMap(),
Type(getSinglyDesugaredType()));
}

void NameAliasType::Profile(
void TypeAliasType::Profile(
llvm::FoldingSetNodeID &id,
TypeAliasDecl *typealias,
Type parent, SubstitutionMap substitutions,
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3227,8 +3227,8 @@ namespace {
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}

void visitNameAliasType(NameAliasType *T, StringRef label) {
printCommon(label, "name_alias_type");
void visitTypeAliasType(TypeAliasType *T, StringRef label) {
printCommon(label, "type_alias_type");
printField("decl", T->getDecl()->printRef());
if (T->getParent())
printRec("parent", T->getParent());
Expand Down
12 changes: 6 additions & 6 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static bool shouldMangleAsGeneric(Type type) {
if (!type)
return false;

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

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

// It's not possible to mangle the context of the builtin module.
// For the DWARF output we want to mangle the type alias + context,
Expand Down Expand Up @@ -834,7 +834,7 @@ void ASTMangler::appendType(Type type) {
case TypeKind::BoundGenericEnum:
case TypeKind::BoundGenericStruct: {
GenericTypeDecl *Decl;
if (auto typeAlias = dyn_cast<NameAliasType>(type.getPointer()))
if (auto typeAlias = dyn_cast<TypeAliasType>(type.getPointer()))
Decl = typeAlias->getDecl();
else
Decl = type->getAnyGeneric();
Expand Down Expand Up @@ -1075,7 +1075,7 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
void ASTMangler::appendBoundGenericArgs(Type type, bool &isFirstArgList) {
TypeBase *typePtr = type.getPointer();
ArrayRef<Type> genericArgs;
if (auto *typeAlias = dyn_cast<NameAliasType>(typePtr)) {
if (auto *typeAlias = dyn_cast<TypeAliasType>(typePtr)) {
appendBoundGenericArgs(typeAlias->getDecl(),
typeAlias->getSubstitutionMap(),
isFirstArgList);
Expand Down Expand Up @@ -1177,7 +1177,7 @@ void ASTMangler::appendRetroactiveConformances(Type type) {
// Dig out the substitution map to use.
SubstitutionMap subMap;
ModuleDecl *module;
if (auto typeAlias = dyn_cast<NameAliasType>(type.getPointer())) {
if (auto typeAlias = dyn_cast<TypeAliasType>(type.getPointer())) {
module = Mod ? Mod : typeAlias->getDecl()->getModuleContext();
subMap = typeAlias->getSubstitutionMap();
} else {
Expand Down
8 changes: 4 additions & 4 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static bool isPublicOrUsableFromInline(Type ty) {
return !ty.findIf([](Type typePart) -> bool {
// FIXME: If we have an internal typealias for a non-internal type, we ought
// to be able to print it by desugaring.
if (auto *aliasTy = dyn_cast<NameAliasType>(typePart.getPointer()))
if (auto *aliasTy = dyn_cast<TypeAliasType>(typePart.getPointer()))
return !isPublicOrUsableFromInline(aliasTy->getDecl());
if (auto *nominal = typePart->getAnyNominal())
return !isPublicOrUsableFromInline(nominal);
Expand Down Expand Up @@ -3452,8 +3452,8 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
Printer << BUILTIN_TYPE_NAME_SILTOKEN;
}

void visitNameAliasType(NameAliasType *T) {
if (Options.PrintForSIL || Options.PrintNameAliasUnderlyingType) {
void visitTypeAliasType(TypeAliasType *T) {
if (Options.PrintForSIL || Options.PrintTypeAliasUnderlyingType) {
visit(T->getSinglyDesugaredType());
return;
}
Expand Down Expand Up @@ -4472,7 +4472,7 @@ swift::getInheritedForPrinting(const Decl *decl,
for (auto TL: inherited) {
if (auto ty = TL.getType()) {
bool foundUnprintable = ty.findIf([shouldPrint](Type subTy) {
if (auto aliasTy = dyn_cast<NameAliasType>(subTy.getPointer()))
if (auto aliasTy = dyn_cast<TypeAliasType>(subTy.getPointer()))
return !shouldPrint(aliasTy->getDecl());
if (auto NTD = subTy->getAnyNominal())
return !shouldPrint(NTD);
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/AccessScopeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TypeAccessScopeChecker::TypeAccessScopeChecker(const DeclContext *useDC,
TypeWalker::Action
TypeAccessScopeChecker::walkToTypePre(Type T) {
ValueDecl *VD;
if (auto *BNAD = dyn_cast<NameAliasType>(T.getPointer()))
if (auto *BNAD = dyn_cast<TypeAliasType>(T.getPointer()))
VD = BNAD->getDecl();
else if (auto *NTD = T->getAnyNominal())
VD = NTD;
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3245,7 +3245,7 @@ void TypeAliasDecl::setUnderlyingType(Type underlying) {
auto parentDC = getDeclContext();
if (parentDC->isTypeContext())
parent = parentDC->getDeclaredInterfaceType();
auto sugaredType = NameAliasType::get(this, parent, subs, underlying);
auto sugaredType = TypeAliasType::get(this, parent, subs, underlying);
setInterfaceType(MetatypeType::get(sugaredType, ctx));
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static void formatSelectionArgument(StringRef ModifierArguments,
static bool isInterestingTypealias(Type type) {
// Dig out the typealias declaration, if there is one.
TypeAliasDecl *aliasDecl = nullptr;
if (auto aliasTy = dyn_cast<NameAliasType>(type.getPointer()))
if (auto aliasTy = dyn_cast<TypeAliasType>(type.getPointer()))
aliasDecl = aliasTy->getDecl();
else
return false;
Expand Down
8 changes: 4 additions & 4 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3856,7 +3856,7 @@ static Type substituteConcreteType(GenericSignatureBuilder &builder,

// If we had a typealias, form a sugared type.
if (typealias) {
type = NameAliasType::get(typealias, parentType, subMap, type);
type = TypeAliasType::get(typealias, parentType, subMap, type);
}

return type;
Expand Down Expand Up @@ -5315,13 +5315,13 @@ class GenericSignatureBuilder::InferRequirementsWalker : public TypeWalker {

Action walkToTypePost(Type ty) override {
// Infer from generic typealiases.
if (auto NameAlias = dyn_cast<NameAliasType>(ty.getPointer())) {
auto decl = NameAlias->getDecl();
if (auto TypeAlias = dyn_cast<TypeAliasType>(ty.getPointer())) {
auto decl = TypeAlias->getDecl();
auto genericSig = decl->getGenericSignature();
if (!genericSig)
return Action::Continue;

auto subMap = NameAlias->getSubstitutionMap();
auto subMap = TypeAlias->getSubstitutionMap();
for (const auto &rawReq : genericSig->getRequirements()) {
if (auto req = rawReq.subst(subMap))
Builder.addRequirement(*req, source, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/NameLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,7 @@ directReferencesForTypeRepr(Evaluator &evaluator,

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

// If there is a generic declaration, return it.
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/PrettyStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace {
Decl *visitNominalType(NominalType *type) {
return type->getDecl();
}
Decl *visitNameAliasType(NameAliasType *type) {
Decl *visitTypeAliasType(TypeAliasType *type) {
return type->getDecl();
}
};
Expand Down
Loading