Skip to content

Commit 5d40673

Browse files
committed
Sema: Fix call to SubstitutionMap::getProtocolSubstitutions()
The conforming type didn't match the conformance, which is going to be flagged by SubstitutionMap::verify().
1 parent 1fc2cd9 commit 5d40673

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include "swift/AST/ConformanceLookup.h"
4040
#include "swift/AST/Decl.h"
41+
#include "swift/AST/GenericEnvironment.h"
4142
#include "swift/AST/GenericSignature.h"
4243
#include "swift/AST/NameLookupRequests.h"
4344
#include "swift/AST/PrettyStackTrace.h"
@@ -2860,12 +2861,18 @@ bool AssociatedTypeInference::checkCurrentTypeWitnesses(
28602861
// Check any same-type requirements in the protocol's requirement signature.
28612862
SubstOptions options = getSubstOptionsWithCurrentTypeWitnesses();
28622863

2863-
auto typeInContext = dc->mapTypeIntoContext(adoptee);
2864+
auto typeInContext = adoptee;
2865+
ProtocolConformanceRef conformanceInContext(conformance);
2866+
if (auto *genericEnv = conformance->getGenericEnvironment()) {
2867+
typeInContext = genericEnv->mapTypeIntoContext(typeInContext);
2868+
conformanceInContext =
2869+
conformanceInContext.subst(conformance->getType(),
2870+
genericEnv->getForwardingSubstitutionMap());
2871+
}
28642872

28652873
auto substitutions =
28662874
SubstitutionMap::getProtocolSubstitutions(
2867-
proto, typeInContext,
2868-
ProtocolConformanceRef(conformance));
2875+
proto, typeInContext, conformanceInContext);
28692876

28702877
SmallVector<Requirement, 4> sanitizedRequirements;
28712878
auto requirements = proto->getRequirementSignature().getRequirements();

0 commit comments

Comments
 (0)