Skip to content

Commit 475d9b7

Browse files
committed
AST: Tweak LookUpConformanceInSubstitutionMap
1 parent d5b4a17 commit 475d9b7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ operator()(CanType dependentType, Type conformingReplacementType,
200200
ProtocolConformanceRef LookUpConformanceInSubstitutionMap::
201201
operator()(CanType dependentType, Type conformingReplacementType,
202202
ProtocolDecl *conformedProtocol) const {
203-
auto result = Subs.lookupConformance(dependentType, conformedProtocol);
204-
if (!result.isInvalid())
205-
return result;
206-
207203
// Lookup conformances for archetypes that conform concretely
208204
// via a superclass.
209205
if (auto archetypeType = conformingReplacementType->getAs<ArchetypeType>()) {
@@ -212,10 +208,15 @@ operator()(CanType dependentType, Type conformingReplacementType,
212208
/*allowMissing=*/true);
213209
}
214210

211+
auto result = Subs.lookupConformance(dependentType, conformedProtocol);
212+
if (!result.isInvalid())
213+
return result;
214+
215215
// Otherwise, the original type might be fixed to a concrete type in
216216
// the substitution map's input generic signature.
217217
if (auto genericSig = Subs.getGenericSignature()) {
218-
if (genericSig->isConcreteType(dependentType)) {
218+
if (genericSig->isValidTypeParameter(dependentType) &&
219+
genericSig->isConcreteType(dependentType)) {
219220
return conformedProtocol->getModuleContext()->lookupConformance(
220221
conformingReplacementType, conformedProtocol,
221222
/*allowMissing=*/true);

0 commit comments

Comments
 (0)