Skip to content

Commit 34d3236

Browse files
committed
GSB: Avoid re-resolving FloatingRequirementSources
1 parent 8ae1b76 commit 34d3236

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class GenericSignatureBuilder {
211211
bool recordConformanceConstraint(GenericSignatureBuilder &builder,
212212
ResolvedType type,
213213
ProtocolDecl *proto,
214-
FloatingRequirementSource source);
214+
const RequirementSource *source);
215215

216216
/// Find a source of the same-type constraint that maps a potential
217217
/// archetype in this equivalence class to a concrete type along with

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ bool EquivalenceClass::recordConformanceConstraint(
17101710
GenericSignatureBuilder &builder,
17111711
ResolvedType type,
17121712
ProtocolDecl *proto,
1713-
FloatingRequirementSource source) {
1713+
const RequirementSource *source) {
17141714
// If we haven't seen a conformance to this protocol yet, add it.
17151715
bool inserted = false;
17161716
auto known = conformsTo.find(proto);
@@ -1730,8 +1730,7 @@ bool EquivalenceClass::recordConformanceConstraint(
17301730
}
17311731

17321732
// Record this conformance source.
1733-
known->second.push_back({type.getUnresolvedType(), proto,
1734-
source.getSource(builder, type)});
1733+
known->second.push_back({type.getUnresolvedType(), proto, source});
17351734
++NumConformanceConstraints;
17361735

17371736
return inserted;
@@ -4167,13 +4166,15 @@ ConstraintResult GenericSignatureBuilder::addConformanceRequirement(
41674166
ResolvedType type,
41684167
ProtocolDecl *proto,
41694168
FloatingRequirementSource source) {
4169+
auto resolvedSource = source.getSource(*this, type);
4170+
41704171
// Add the conformance requirement, bailing out earlier if we've already
41714172
// seen it.
41724173
auto equivClass = type.getEquivalenceClass(*this);
4173-
if (!equivClass->recordConformanceConstraint(*this, type, proto, source))
4174+
if (!equivClass->recordConformanceConstraint(*this, type, proto,
4175+
resolvedSource))
41744176
return ConstraintResult::Resolved;
41754177

4176-
auto resolvedSource = source.getSource(*this, type);
41774178
return expandConformanceRequirement(type, proto, resolvedSource,
41784179
/*onlySameTypeRequirements=*/false);
41794180
}
@@ -4325,7 +4326,7 @@ ConstraintResult GenericSignatureBuilder::addSuperclassRequirementDirect(
43254326
++NumSuperclassConstraints;
43264327

43274328
// Update the equivalence class with the constraint.
4328-
if (!updateSuperclass(type, superclass, source))
4329+
if (!updateSuperclass(type, superclass, resolvedSource))
43294330
++NumSuperclassConstraintsExtra;
43304331

43314332
return ConstraintResult::Resolved;

0 commit comments

Comments
 (0)