@@ -200,10 +200,6 @@ operator()(CanType dependentType, Type conformingReplacementType,
200200ProtocolConformanceRef LookUpConformanceInSubstitutionMap::
201201operator ()(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