Skip to content

[Generic signature builder] Use addSameTypeRequirementBetweenArchetypes consistently #7391

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 2 commits into from
Feb 11, 2017
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
2 changes: 1 addition & 1 deletion include/swift/AST/TypeNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#define TYPE_RANGE(Id, First, Last)
#endif

UNCHECKED_TYPE(Error, Type)
TYPE(Error, Type)
UNCHECKED_TYPE(Unresolved, Type)
ABSTRACT_TYPE(Builtin, Type)
BUILTIN_TYPE(BuiltinInteger, BuiltinType)
Expand Down
16 changes: 4 additions & 12 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,9 @@ bool GenericSignatureBuilder::PotentialArchetype::addConformance(
// Otherwise, create a new potential archetype for this associated type
// and make it equivalent to the first potential archetype we encountered.
auto otherPA = new PotentialArchetype(this, assocType);
otherPA->addSameTypeConstraint(known->second.front(), redundantSource);

// Update the equivalence class.
auto frontRep = known->second.front()->getRepresentative();
otherPA->Representative = frontRep;
frontRep->EquivalenceClass.push_back(otherPA);

known->second.push_back(otherPA);
builder.addSameTypeRequirementBetweenArchetypes(known->second.front(),
otherPA, redundantSource);

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

// Produce a same-type constraint between the two same-named
// potential archetypes.
pa->addSameTypeConstraint(nested.front(), redundantSource);

auto frontRep = nested.front()->getRepresentative();
pa->Representative = frontRep;
frontRep->EquivalenceClass.push_back(pa);
builder.addSameTypeRequirementBetweenArchetypes(pa, existing,
redundantSource);
} else {
nested.push_back(pa);

Expand Down
2 changes: 2 additions & 0 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ TypeBase *TypeBase::getDesugaredType() {
#define UNCHECKED_TYPE(id, parent) case TypeKind::id:
#define TYPE(id, parent)
#include "swift/AST/TypeNodes.def"
case TypeKind::Error:
case TypeKind::Tuple:
case TypeKind::Function:
case TypeKind::GenericFunction:
Expand Down Expand Up @@ -1476,6 +1477,7 @@ bool TypeBase::isSpelledLike(Type other) {
#define UNCHECKED_TYPE(id, parent) case TypeKind::id:
#define TYPE(id, parent)
#include "swift/AST/TypeNodes.def"
case TypeKind::Error:
case TypeKind::Enum:
case TypeKind::Struct:
case TypeKind::Class:
Expand Down
1 change: 1 addition & 0 deletions lib/IRGen/Fulfillment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static bool isLeafTypeMetadata(CanType type) {
case TypeKind::ID:
#define TYPE(ID, SUPER)
#include "swift/AST/TypeNodes.def"
case TypeKind::Error:
llvm_unreachable("kind is invalid for a canonical type");

#define ARTIFICIAL_TYPE(ID, SUPER) \
Expand Down
5 changes: 4 additions & 1 deletion lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,10 @@ namespace {
llvm::Value *visitInOutType(CanInOutType type) {
llvm_unreachable("inout type should have been lowered by SILGen");
}

llvm::Value *visitErrorType(CanErrorType type) {
llvm_unreachable("error type should not appear in IRGen");
}

llvm::Value *visitSILBlockStorageType(CanSILBlockStorageType type) {
llvm_unreachable("cannot ask for metadata of block storage");
}
Expand Down
3 changes: 3 additions & 0 deletions lib/IRGen/GenType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ TypeCacheEntry TypeConverter::convertType(CanType ty) {
PrettyStackTraceType stackTrace(IGM.Context, "converting", ty);

switch (ty->getKind()) {
case TypeKind::Error:
llvm_unreachable("found an ErrorType in IR-gen");

#define UNCHECKED_TYPE(id, parent) \
case TypeKind::id: \
llvm_unreachable("found a " #id "Type in IR-gen");
Expand Down
3 changes: 3 additions & 0 deletions lib/SIL/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ namespace {
RetTy visitInOutType(CanInOutType type) {
llvm_unreachable("shouldn't get an inout type here");
}
RetTy visitErrorType(CanErrorType type) {
llvm_unreachable("shouldn't get an error type here");
}

// Dependent types should be contextualized before visiting.

Expand Down