Skip to content

Commit 02e46c1

Browse files
xedinktoso
authored andcommitted
[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 aa5b505 commit 02e46c1

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
@@ -1653,11 +1653,15 @@ class Solution {
16531653
/// Compute the set of substitutions for a generic signature opened at the
16541654
/// given locator.
16551655
///
1656+
/// \param decl The underlying declaration for which the substitutions are
1657+
/// computed.
1658+
///
16561659
/// \param sig The generic signature.
16571660
///
16581661
/// \param locator The locator that describes where the substitutions came
16591662
/// from.
1660-
SubstitutionMap computeSubstitutions(GenericSignature sig,
1663+
SubstitutionMap computeSubstitutions(NullablePtr<ValueDecl> decl,
1664+
GenericSignature sig,
16611665
ConstraintLocator *locator) const;
16621666

16631667
/// 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
@@ -82,7 +82,8 @@ static bool isOpenedAnyObject(Type type) {
8282
}
8383

8484
SubstitutionMap
85-
Solution::computeSubstitutions(GenericSignature sig,
85+
Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
86+
GenericSignature sig,
8687
ConstraintLocator *locator) const {
8788
if (sig.isNull())
8889
return SubstitutionMap();
@@ -147,7 +148,7 @@ Solution::resolveConcreteDeclRef(ValueDecl *decl,
147148

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

152153
maybeInstantiateCXXMethodDefinition(decl);
153154

@@ -7121,7 +7122,8 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
71217122
auto opaqueLocator = solution.getConstraintSystem().getOpenOpaqueLocator(
71227123
locator, opaqueDecl);
71237124
SubstitutionMap substitutions = solution.computeSubstitutions(
7124-
opaqueDecl->getOpaqueInterfaceGenericSignature(), opaqueLocator);
7125+
opaqueDecl, opaqueDecl->getOpaqueInterfaceGenericSignature(),
7126+
opaqueLocator);
71257127

71267128
// If we don't have substitutions, this is an opaque archetype from
71277129
// 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
@@ -1231,8 +1231,8 @@ swift::matchWitness(WitnessChecker::RequirementEnvironmentCache &reqEnvCache,
12311231
auto witnessSig =
12321232
witness->getInnermostDeclContext()->getGenericSignatureOfContext();
12331233
result.WitnessSubstitutions =
1234-
solution->computeSubstitutions(witnessSig, witnessLocator);
1235-
1234+
solution->computeSubstitutions(witness, witnessSig, witnessLocator);
1235+
12361236
return result;
12371237
};
12381238

0 commit comments

Comments
 (0)