Skip to content

Commit

Permalink
Merge pull request swiftlang#33999 from AnthonyLatsis/cleanups/get-op…
Browse files Browse the repository at this point in the history
…ened-archetype-signature

ASTContext: Tidy up the interface of getOpenedArchetypeSignature
  • Loading branch information
AnthonyLatsis committed Sep 20, 2020
2 parents 4586f1a + 8ee7b8f commit 8bc13cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1065,9 +1065,8 @@ class ASTContext final {
CanGenericSignature getSingleGenericParameterSignature() const;

/// Retrieve a generic signature with a single type parameter conforming
/// to the given opened archetype.
CanGenericSignature getOpenedArchetypeSignature(CanType existential,
ModuleDecl *mod);
/// to the given protocol or composition type, like <T: type>.
CanGenericSignature getOpenedArchetypeSignature(Type type);

GenericSignature getOverrideGenericSignature(const ValueDecl *base,
const ValueDecl *derived);
Expand Down
10 changes: 5 additions & 5 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3937,8 +3937,7 @@ GenericEnvironment *OpenedArchetypeType::getGenericEnvironment() const {
auto thisType = Type(const_cast<OpenedArchetypeType*>(this));
auto &ctx = thisType->getASTContext();
// Create a generic environment to represent the opened type.
auto signature =
ctx.getOpenedArchetypeSignature(Opened->getCanonicalType(), nullptr);
auto signature = ctx.getOpenedArchetypeSignature(Opened);
auto *builder = signature->getGenericSignatureBuilder();
auto *env = GenericEnvironment::getIncomplete(signature, builder);
env->addMapping(signature->getGenericParams()[0], thisType);
Expand Down Expand Up @@ -4567,9 +4566,10 @@ CanGenericSignature ASTContext::getSingleGenericParameterSignature() const {
// Type::getExistentialLayout()). In particular, the opened archetype signature
// does not have requirements for conformances inherited from superclass
// constraints while existential values do.
CanGenericSignature ASTContext::getOpenedArchetypeSignature(CanType existential,
ModuleDecl *mod) {
assert(existential.isExistentialType());
CanGenericSignature ASTContext::getOpenedArchetypeSignature(Type type) {
assert(type->isExistentialType());

const CanType existential = type->getCanonicalType();

// The opened archetype signature for a protocol type is identical
// to the protocol's own canonical generic signature.
Expand Down
3 changes: 1 addition & 2 deletions lib/SILOptimizer/Utils/Existential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ void ConcreteExistentialInfo::initializeSubstitutionMap(
// than their corresponding existential, ExistentialConformances needs to be
// filtered when using it with this (phony) generic signature.
CanGenericSignature ExistentialSig =
M->getASTContext().getOpenedArchetypeSignature(ExistentialType,
M->getSwiftModule());
M->getASTContext().getOpenedArchetypeSignature(ExistentialType);
ExistentialSubs = SubstitutionMap::get(
ExistentialSig, [&](SubstitutableType *type) { return ConcreteType; },
[&](CanType /*depType*/, Type /*replaceType*/,
Expand Down

0 comments on commit 8bc13cb

Please sign in to comment.