Skip to content

Commit 29a086d

Browse files
committed
[ConstraintSystem] NFC: Pass an underlying declaration to Solution::computeSubstitutions
This is going to be used to determine whether the substitutions are computed for `DistributedActorSystem::remoteCall` and adjust the generic signature with witness conformance requirements.
1 parent 72486c9 commit 29a086d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,11 +1667,15 @@ class Solution {
16671667
/// Compute the set of substitutions for a generic signature opened at the
16681668
/// given locator.
16691669
///
1670+
/// \param decl The underlying declaration for which the substitutions are
1671+
/// computed.
1672+
///
16701673
/// \param sig The generic signature.
16711674
///
16721675
/// \param locator The locator that describes where the substitutions came
16731676
/// from.
1674-
SubstitutionMap computeSubstitutions(GenericSignature sig,
1677+
SubstitutionMap computeSubstitutions(NullablePtr<ValueDecl> decl,
1678+
GenericSignature sig,
16751679
ConstraintLocator *locator) const;
16761680

16771681
/// Resolves the contextual substitutions for a reference to a declaration

lib/Sema/CSApply.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ static bool isOpenedAnyObject(Type type) {
8383
}
8484

8585
SubstitutionMap
86-
Solution::computeSubstitutions(GenericSignature sig,
86+
Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
87+
GenericSignature sig,
8788
ConstraintLocator *locator) const {
8889
if (sig.isNull())
8990
return SubstitutionMap();
@@ -148,7 +149,7 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
148149

149150
// Get the generic signature of the decl and compute the substitutions.
150151
auto sig = decl->getInnermostDeclContext()->getGenericSignatureOfContext();
151-
auto subst = computeSubstitutions(sig, locator);
152+
auto subst = computeSubstitutions(decl, sig, locator);
152153

153154
maybeInstantiateCXXMethodDefinition(decl);
154155

@@ -7132,7 +7133,8 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
71327133
auto opaqueLocator = solution.getConstraintSystem().getOpenOpaqueLocator(
71337134
locator, opaqueDecl);
71347135
SubstitutionMap substitutions = solution.computeSubstitutions(
7135-
opaqueDecl->getOpaqueInterfaceGenericSignature(), opaqueLocator);
7136+
opaqueDecl, opaqueDecl->getOpaqueInterfaceGenericSignature(),
7137+
opaqueLocator);
71367138

71377139
// If we don't have substitutions, this is an opaque archetype from
71387140
// another declaration being manipulated, and not an erasure of a

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,8 +1273,8 @@ swift::matchWitness(WitnessChecker::RequirementEnvironmentCache &reqEnvCache,
12731273
auto witnessSig =
12741274
witness->getInnermostDeclContext()->getGenericSignatureOfContext();
12751275
result.WitnessSubstitutions =
1276-
solution->computeSubstitutions(witnessSig, witnessLocator);
1277-
1276+
solution->computeSubstitutions(witness, witnessSig, witnessLocator);
1277+
12781278
return result;
12791279
};
12801280

0 commit comments

Comments
 (0)