Skip to content

Commit 8bc13cb

Browse files
Merge pull request #33999 from AnthonyLatsis/cleanups/get-opened-archetype-signature
ASTContext: Tidy up the interface of getOpenedArchetypeSignature
2 parents 4586f1a + 8ee7b8f commit 8bc13cb

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

include/swift/AST/ASTContext.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,8 @@ class ASTContext final {
10651065
CanGenericSignature getSingleGenericParameterSignature() const;
10661066

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

10721071
GenericSignature getOverrideGenericSignature(const ValueDecl *base,
10731072
const ValueDecl *derived);

lib/AST/ASTContext.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,8 +3937,7 @@ GenericEnvironment *OpenedArchetypeType::getGenericEnvironment() const {
39373937
auto thisType = Type(const_cast<OpenedArchetypeType*>(this));
39383938
auto &ctx = thisType->getASTContext();
39393939
// Create a generic environment to represent the opened type.
3940-
auto signature =
3941-
ctx.getOpenedArchetypeSignature(Opened->getCanonicalType(), nullptr);
3940+
auto signature = ctx.getOpenedArchetypeSignature(Opened);
39423941
auto *builder = signature->getGenericSignatureBuilder();
39433942
auto *env = GenericEnvironment::getIncomplete(signature, builder);
39443943
env->addMapping(signature->getGenericParams()[0], thisType);
@@ -4567,9 +4566,10 @@ CanGenericSignature ASTContext::getSingleGenericParameterSignature() const {
45674566
// Type::getExistentialLayout()). In particular, the opened archetype signature
45684567
// does not have requirements for conformances inherited from superclass
45694568
// constraints while existential values do.
4570-
CanGenericSignature ASTContext::getOpenedArchetypeSignature(CanType existential,
4571-
ModuleDecl *mod) {
4572-
assert(existential.isExistentialType());
4569+
CanGenericSignature ASTContext::getOpenedArchetypeSignature(Type type) {
4570+
assert(type->isExistentialType());
4571+
4572+
const CanType existential = type->getCanonicalType();
45734573

45744574
// The opened archetype signature for a protocol type is identical
45754575
// to the protocol's own canonical generic signature.

lib/SILOptimizer/Utils/Existential.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@ void ConcreteExistentialInfo::initializeSubstitutionMap(
255255
// than their corresponding existential, ExistentialConformances needs to be
256256
// filtered when using it with this (phony) generic signature.
257257
CanGenericSignature ExistentialSig =
258-
M->getASTContext().getOpenedArchetypeSignature(ExistentialType,
259-
M->getSwiftModule());
258+
M->getASTContext().getOpenedArchetypeSignature(ExistentialType);
260259
ExistentialSubs = SubstitutionMap::get(
261260
ExistentialSig, [&](SubstitutableType *type) { return ConcreteType; },
262261
[&](CanType /*depType*/, Type /*replaceType*/,

0 commit comments

Comments
 (0)