Skip to content

Commit 972f048

Browse files
committed
[GSB] Teach expandConformanceRequirement() to use a resolved type.
Eliminates another too-early source of realization of potential archetypes.
1 parent 28e3e5c commit 972f048

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class GenericSignatureBuilder {
363363
/// adding the requirements from its requirement signature, rooted at
364364
/// the given requirement \c source.
365365
ConstraintResult expandConformanceRequirement(
366-
PotentialArchetype *pa,
366+
ResolvedType selfType,
367367
ProtocolDecl *proto,
368368
const RequirementSource *source,
369369
bool onlySameTypeConstraints);

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,13 +3301,12 @@ static ConstraintResult visitInherited(
33013301
}
33023302

33033303
ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
3304-
PotentialArchetype *pa,
3304+
ResolvedType selfType,
33053305
ProtocolDecl *proto,
33063306
const RequirementSource *source,
33073307
bool onlySameTypeConstraints) {
3308-
auto concreteSelf = pa->getDependentType({});
33093308
auto protocolSubMap = SubstitutionMap::getProtocolSubstitutions(
3310-
proto, concreteSelf, ProtocolConformanceRef(proto));
3309+
proto, selfType.getDependentType(), ProtocolConformanceRef(proto));
33113310

33123311
// Use the requirement signature to avoid rewalking the entire protocol. This
33133312
// cannot compute the requirement signature directly, because that may be
@@ -3339,7 +3338,8 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
33393338
resolver->resolveInheritedProtocols(proto);
33403339

33413340
auto inheritedReqResult =
3342-
addInheritedRequirements(proto, pa, source, protoModule);
3341+
addInheritedRequirements(proto, selfType.getUnresolvedType(), source,
3342+
protoModule);
33433343
if (isErrorResult(inheritedReqResult))
33443344
return inheritedReqResult;
33453345
}
@@ -3467,7 +3467,8 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
34673467
for (auto Member : proto->getMembers()) {
34683468
if (auto assocTypeDecl = dyn_cast<AssociatedTypeDecl>(Member)) {
34693469
// Add requirements placed directly on this associated type.
3470-
Type assocType = DependentMemberType::get(concreteSelf, assocTypeDecl);
3470+
Type assocType =
3471+
DependentMemberType::get(selfType.getDependentType(), assocTypeDecl);
34713472
if (!onlySameTypeConstraints) {
34723473
auto assocResult =
34733474
addInheritedRequirements(assocTypeDecl, assocType, source,
@@ -3614,10 +3615,8 @@ ConstraintResult GenericSignatureBuilder::addConformanceRequirement(
36143615
if (!equivClass->recordConformanceConstraint(type, proto, source))
36153616
return ConstraintResult::Resolved;
36163617

3617-
// FIXME: Resolve later.
3618-
auto pa = type.realizePotentialArchetype(*this);
36193618
auto resolvedSource = source.getSource(*this, type.getDependentType());
3620-
return expandConformanceRequirement(pa, proto, resolvedSource,
3619+
return expandConformanceRequirement(type, proto, resolvedSource,
36213620
/*onlySameTypeRequirements=*/false);
36223621
}
36233622

0 commit comments

Comments
 (0)