Skip to content

Commit 8ee7b8f

Browse files
committed
ASTContext: Tidy up the interface of getOpenedArchetypeSignature
Drop a dead parameter, encapsulate input type canonicalization, and slightly improve the doc comment.
1 parent 1e0a9ca commit 8ee7b8f

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Diff for: include/swift/AST/ASTContext.h

+2-3
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);

Diff for: lib/AST/ASTContext.cpp

+5-5
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.

Diff for: lib/SILOptimizer/Utils/Existential.cpp

+1-2
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)