Skip to content

Commit 1ab9af6

Browse files
authored
Merge pull request swiftlang#7391 from DougGregor/consistent-same-type-req
2 parents f2f522c + aa42045 commit 1ab9af6

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

include/swift/AST/TypeNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#define TYPE_RANGE(Id, First, Last)
8484
#endif
8585

86-
UNCHECKED_TYPE(Error, Type)
86+
TYPE(Error, Type)
8787
UNCHECKED_TYPE(Unresolved, Type)
8888
ABSTRACT_TYPE(Builtin, Type)
8989
BUILTIN_TYPE(BuiltinInteger, BuiltinType)

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,9 @@ bool GenericSignatureBuilder::PotentialArchetype::addConformance(
313313
// Otherwise, create a new potential archetype for this associated type
314314
// and make it equivalent to the first potential archetype we encountered.
315315
auto otherPA = new PotentialArchetype(this, assocType);
316-
otherPA->addSameTypeConstraint(known->second.front(), redundantSource);
317-
318-
// Update the equivalence class.
319-
auto frontRep = known->second.front()->getRepresentative();
320-
otherPA->Representative = frontRep;
321-
frontRep->EquivalenceClass.push_back(otherPA);
322-
323316
known->second.push_back(otherPA);
317+
builder.addSameTypeRequirementBetweenArchetypes(known->second.front(),
318+
otherPA, redundantSource);
324319

325320
// If there's a superclass constraint that conforms to the protocol,
326321
// add the appropriate same-type relationship.
@@ -630,11 +625,8 @@ auto GenericSignatureBuilder::PotentialArchetype::getNestedType(
630625

631626
// Produce a same-type constraint between the two same-named
632627
// potential archetypes.
633-
pa->addSameTypeConstraint(nested.front(), redundantSource);
634-
635-
auto frontRep = nested.front()->getRepresentative();
636-
pa->Representative = frontRep;
637-
frontRep->EquivalenceClass.push_back(pa);
628+
builder.addSameTypeRequirementBetweenArchetypes(pa, existing,
629+
redundantSource);
638630
} else {
639631
nested.push_back(pa);
640632

lib/AST/Type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,7 @@ TypeBase *TypeBase::getDesugaredType() {
13131313
#define UNCHECKED_TYPE(id, parent) case TypeKind::id:
13141314
#define TYPE(id, parent)
13151315
#include "swift/AST/TypeNodes.def"
1316+
case TypeKind::Error:
13161317
case TypeKind::Tuple:
13171318
case TypeKind::Function:
13181319
case TypeKind::GenericFunction:
@@ -1476,6 +1477,7 @@ bool TypeBase::isSpelledLike(Type other) {
14761477
#define UNCHECKED_TYPE(id, parent) case TypeKind::id:
14771478
#define TYPE(id, parent)
14781479
#include "swift/AST/TypeNodes.def"
1480+
case TypeKind::Error:
14791481
case TypeKind::Enum:
14801482
case TypeKind::Struct:
14811483
case TypeKind::Class:

lib/IRGen/Fulfillment.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static bool isLeafTypeMetadata(CanType type) {
3838
case TypeKind::ID:
3939
#define TYPE(ID, SUPER)
4040
#include "swift/AST/TypeNodes.def"
41+
case TypeKind::Error:
4142
llvm_unreachable("kind is invalid for a canonical type");
4243

4344
#define ARTIFICIAL_TYPE(ID, SUPER) \

lib/IRGen/GenMeta.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,10 @@ namespace {
10051005
llvm::Value *visitInOutType(CanInOutType type) {
10061006
llvm_unreachable("inout type should have been lowered by SILGen");
10071007
}
1008-
1008+
llvm::Value *visitErrorType(CanErrorType type) {
1009+
llvm_unreachable("error type should not appear in IRGen");
1010+
}
1011+
10091012
llvm::Value *visitSILBlockStorageType(CanSILBlockStorageType type) {
10101013
llvm_unreachable("cannot ask for metadata of block storage");
10111014
}

lib/IRGen/GenType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,9 @@ TypeCacheEntry TypeConverter::convertType(CanType ty) {
11551155
PrettyStackTraceType stackTrace(IGM.Context, "converting", ty);
11561156

11571157
switch (ty->getKind()) {
1158+
case TypeKind::Error:
1159+
llvm_unreachable("found an ErrorType in IR-gen");
1160+
11581161
#define UNCHECKED_TYPE(id, parent) \
11591162
case TypeKind::id: \
11601163
llvm_unreachable("found a " #id "Type in IR-gen");

lib/SIL/TypeLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ namespace {
230230
RetTy visitInOutType(CanInOutType type) {
231231
llvm_unreachable("shouldn't get an inout type here");
232232
}
233+
RetTy visitErrorType(CanErrorType type) {
234+
llvm_unreachable("shouldn't get an error type here");
235+
}
233236

234237
// Dependent types should be contextualized before visiting.
235238

0 commit comments

Comments
 (0)