Skip to content

Commit b3fe5c9

Browse files
authored
Merge pull request #6012 from slavapestov/remove-associated-type-type
AST: Remove AssociatedTypeType
2 parents 39e4455 + 52b91ad commit b3fe5c9

File tree

14 files changed

+1
-101
lines changed

14 files changed

+1
-101
lines changed

include/swift/AST/TypeMatcher.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ class TypeMatcher {
211211
TRIVIAL_CASE(DynamicSelfType)
212212
TRIVIAL_CASE(ArchetypeType)
213213
TRIVIAL_CASE(GenericTypeParamType)
214-
TRIVIAL_CASE(AssociatedTypeType)
215214

216215
bool visitDependentMemberType(CanDependentMemberType firstDepMember,
217216
Type secondType) {

include/swift/AST/TypeNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ ABSTRACT_TYPE(Substitutable, Type)
118118
ALWAYS_CANONICAL_TYPE(Archetype, SubstitutableType)
119119
TYPE(GenericTypeParam, SubstitutableType)
120120
TYPE_RANGE(Substitutable, Archetype, GenericTypeParam)
121-
SUGARED_TYPE(AssociatedType, Type)
122121
SUGARED_TYPE(Substituted, Type)
123122
TYPE(DependentMember, Type)
124123
ABSTRACT_TYPE(AnyFunction, Type)

include/swift/AST/Types.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4064,36 +4064,6 @@ BEGIN_CAN_TYPE_WRAPPER(GenericTypeParamType, SubstitutableType)
40644064
}
40654065
END_CAN_TYPE_WRAPPER(GenericTypeParamType, SubstitutableType)
40664066

4067-
/// Describes the type of an associated type.
4068-
///
4069-
/// \sa AssociatedTypeDecl
4070-
class AssociatedTypeType : public TypeBase {
4071-
/// The generic type parameter.
4072-
AssociatedTypeDecl *AssocType;
4073-
4074-
public:
4075-
/// Retrieve the declaration of the associated type.
4076-
AssociatedTypeDecl *getDecl() const { return AssocType; }
4077-
4078-
/// Remove one level of top-level sugar from this type.
4079-
TypeBase *getSinglyDesugaredType();
4080-
4081-
// Implement isa/cast/dyncast/etc.
4082-
static bool classof(const TypeBase *T) {
4083-
return T->getKind() == TypeKind::AssociatedType;
4084-
}
4085-
4086-
private:
4087-
friend class AssociatedTypeDecl;
4088-
4089-
// These aren't classified as dependent for some reason.
4090-
4091-
AssociatedTypeType(AssociatedTypeDecl *assocType)
4092-
: TypeBase(TypeKind::AssociatedType, nullptr, RecursiveTypeProperties()),
4093-
AssocType(assocType) { }
4094-
};
4095-
DEFINE_EMPTY_CAN_TYPE_WRAPPER(AssociatedTypeType, Type)
4096-
40974067
/// SubstitutedType - A type that has been substituted for some other type,
40984068
/// which implies that the replacement type meets all of the requirements of
40994069
/// the original type.

include/swift/Serialization/DeclTypeRecordNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
// VERSION_MAJOR in ModuleFormat.h. Names, however, may change.
8181
FIRST_TYPE(NAME_ALIAS, 1)
8282
TYPE(GENERIC_TYPE_PARAM)
83-
TYPE(ASSOCIATED_TYPE) // This is correct! ASSOCIATED_TYPE_TYPE
8483
TYPE(DEPENDENT_MEMBER)
8584
TYPE(NOMINAL)
8685
TYPE(PAREN)

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const uint16_t VERSION_MAJOR = 0;
5454
/// in source control, you should also update the comment to briefly
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
57-
const uint16_t VERSION_MINOR = 288; // Last change: remove context type from subscript
57+
const uint16_t VERSION_MINOR = 289; // Last change: remove AssociatedTypeType
5858

5959
using DeclID = PointerEmbeddedInt<unsigned, 31>;
6060
using DeclIDField = BCFixed<31>;
@@ -553,11 +553,6 @@ namespace decls_block {
553553
BCVBR<4> // index + 1, or zero if we have a generic type parameter decl
554554
>;
555555

556-
using AssociatedTypeTypeLayout = BCRecordLayout<
557-
ASSOCIATED_TYPE_TYPE,
558-
DeclIDField // associated type decl
559-
>;
560-
561556
using DependentMemberTypeLayout = BCRecordLayout<
562557
DEPENDENT_MEMBER_TYPE,
563558
TypeIDField, // base type

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,12 +2855,6 @@ namespace {
28552855
OS << ")";
28562856
}
28572857

2858-
void visitAssociatedTypeType(AssociatedTypeType *T, StringRef label) {
2859-
printCommon(T, label, "associated_type_type");
2860-
printField("decl", T->getDecl()->printRef());
2861-
OS << ")";
2862-
}
2863-
28642858
void visitSubstitutedType(SubstitutedType *T, StringRef label) {
28652859
printCommon(T, label, "substituted_type");
28662860
printRec("original", T->getOriginal());

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,11 +3615,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
36153615

36163616
// We spell normal metatypes of existential types as .Protocol.
36173617
if (isa<MetatypeType>(T) &&
3618-
// Special case AssociatedTypeType's here, since they may not be fully
3619-
// set up within the type checker (preventing getCanonicalType from
3620-
// working), and we want type printing to always work even in malformed
3621-
// programs half way through the type checker.
3622-
!isa<AssociatedTypeType>(T->getInstanceType().getPointer()) &&
36233618
T->getInstanceType()->isAnyExistentialType()) {
36243619
Printer << ".Protocol";
36253620
} else {
@@ -4010,14 +4005,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
40104005
}
40114006
}
40124007

4013-
void visitAssociatedTypeType(AssociatedTypeType *T) {
4014-
auto Name = T->getDecl()->getName();
4015-
if (Name.empty())
4016-
Printer << "<anonymous>";
4017-
else
4018-
Printer.printName(Name);
4019-
}
4020-
40214008
void visitSubstitutedType(SubstitutedType *T) {
40224009
visit(T->getReplacementType());
40234010
}

lib/AST/Mangle.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,6 @@ void Mangler::mangleType(Type type, unsigned uncurryLevel) {
852852

853853
case TypeKind::Paren:
854854
return mangleSugaredType<ParenType>(type);
855-
case TypeKind::AssociatedType:
856-
return mangleSugaredType<AssociatedTypeType>(type);
857855
case TypeKind::Substituted:
858856
return mangleSugaredType<SubstitutedType>(type);
859857
case TypeKind::ArraySlice: /* fallthrough */

lib/AST/Type.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,13 +1430,6 @@ Identifier GenericTypeParamType::getName() const {
14301430
return name;
14311431
}
14321432

1433-
TypeBase *AssociatedTypeType::getSinglyDesugaredType() {
1434-
auto protocolSelf = getDecl()->getProtocol()->getSelfTypeInContext();
1435-
assert(protocolSelf);
1436-
auto *selfArchetype = protocolSelf->castTo<ArchetypeType>();
1437-
return selfArchetype->getNestedTypeValue(getDecl()->getName()).getPointer();
1438-
}
1439-
14401433
const llvm::fltSemantics &BuiltinFloatType::getAPFloatSemantics() const {
14411434
switch (getFPKind()) {
14421435
case BuiltinFloatType::IEEE16: return APFloat::IEEEhalf;
@@ -1469,7 +1462,6 @@ bool TypeBase::isSpelledLike(Type other) {
14691462
case TypeKind::Class:
14701463
case TypeKind::NameAlias:
14711464
case TypeKind::Substituted:
1472-
case TypeKind::AssociatedType:
14731465
case TypeKind::GenericTypeParam:
14741466
case TypeKind::DependentMember:
14751467
case TypeKind::DynamicSelf:
@@ -3122,7 +3114,6 @@ case TypeKind::Id:
31223114
case TypeKind::Error:
31233115
case TypeKind::Unresolved:
31243116
case TypeKind::TypeVariable:
3125-
case TypeKind::AssociatedType:
31263117
case TypeKind::GenericTypeParam:
31273118
return *this;
31283119

lib/AST/TypeWalker.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class Traversal : public TypeVisitor<Traversal, bool>
6767
return doIt(ty->getSelfType());
6868
}
6969
bool visitSubstitutableType(SubstitutableType *ty) { return false; }
70-
bool visitAssociatedTypeType(AssociatedTypeType *ty) { return false; }
7170

7271
bool visitSubstitutedType(SubstitutedType *ty) {
7372
if (Walker.shouldVisitOriginalSubstitutedType())

lib/IRGen/DebugTypeInfo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ TypeDecl *DebugTypeInfo::getDecl() const {
166166
return UBG->getDecl();
167167
if (auto *BG = dyn_cast<BoundGenericType>(Type))
168168
return BG->getDecl();
169-
if (auto *AT = dyn_cast<AssociatedTypeType>(Type))
170-
return AT->getDecl();
171169
return nullptr;
172170
}
173171

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,6 @@ llvm::DIType *IRGenDebugInfo::createType(DebugTypeInfo DbgTy,
17421742

17431743
// The following types exist primarily for internal use by the type
17441744
// checker.
1745-
case TypeKind::AssociatedType:
17461745
case TypeKind::Error:
17471746
case TypeKind::Unresolved:
17481747
case TypeKind::LValue:

lib/Serialization/Deserialization.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,25 +3734,6 @@ Type ModuleFile::getType(TypeID TID) {
37343734
break;
37353735
}
37363736

3737-
case decls_block::ASSOCIATED_TYPE_TYPE: {
3738-
DeclID declID;
3739-
3740-
decls_block::AssociatedTypeTypeLayout::readRecord(scratch, declID);
3741-
3742-
auto assocType = dyn_cast_or_null<AssociatedTypeDecl>(getDecl(declID));
3743-
if (!assocType) {
3744-
error();
3745-
return nullptr;
3746-
}
3747-
3748-
// See if we triggered deserialization through our conformances.
3749-
if (typeOrOffset.isComplete())
3750-
break;
3751-
3752-
typeOrOffset = assocType->getType()->castTo<MetatypeType>()->getInstanceType();
3753-
break;
3754-
}
3755-
37563737
case decls_block::PROTOCOL_COMPOSITION_TYPE: {
37573738
ArrayRef<uint64_t> rawProtocolIDs;
37583739

lib/Serialization/Serialization.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,14 +3018,6 @@ void Serializer::writeType(Type ty) {
30183018
break;
30193019
}
30203020

3021-
case TypeKind::AssociatedType: {
3022-
auto assocType = cast<AssociatedTypeType>(ty.getPointer());
3023-
unsigned abbrCode = DeclTypeAbbrCodes[AssociatedTypeTypeLayout::Code];
3024-
AssociatedTypeTypeLayout::emitRecord(Out, ScratchRecord, abbrCode,
3025-
addDeclRef(assocType->getDecl()));
3026-
break;
3027-
}
3028-
30293021
case TypeKind::Substituted: {
30303022
auto subTy = cast<SubstitutedType>(ty.getPointer());
30313023

@@ -3304,7 +3296,6 @@ void Serializer::writeAllDeclsAndTypes() {
33043296

33053297
registerDeclTypeAbbr<TypeAliasLayout>();
33063298
registerDeclTypeAbbr<GenericTypeParamTypeLayout>();
3307-
registerDeclTypeAbbr<AssociatedTypeTypeLayout>();
33083299
registerDeclTypeAbbr<DependentMemberTypeLayout>();
33093300
registerDeclTypeAbbr<StructLayout>();
33103301
registerDeclTypeAbbr<ConstructorLayout>();

0 commit comments

Comments
 (0)