Skip to content

ASTContext: Tidy up the interface of getOpenedArchetypeSignature #33999

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
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
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