@@ -220,10 +220,6 @@ operator()(CanType dependentType, Type conformingReplacementType,
220220ProtocolConformanceRef LookUpConformanceInSubstitutionMap::
221221operator ()(CanType dependentType, Type conformingReplacementType,
222222 ProtocolDecl *conformedProtocol) const {
223- auto result = Subs.lookupConformance (dependentType, conformedProtocol);
224- if (!result.isInvalid ())
225- return result;
226-
227223 // Lookup conformances for archetypes that conform concretely
228224 // via a superclass.
229225 if (auto archetypeType = conformingReplacementType->getAs <ArchetypeType>()) {
@@ -232,10 +228,15 @@ operator()(CanType dependentType, Type conformingReplacementType,
232228 /* allowMissing=*/ true );
233229 }
234230
231+ auto result = Subs.lookupConformance (dependentType, conformedProtocol);
232+ if (!result.isInvalid ())
233+ return result;
234+
235235 // Otherwise, the original type might be fixed to a concrete type in
236236 // the substitution map's input generic signature.
237237 if (auto genericSig = Subs.getGenericSignature ()) {
238- if (genericSig->isConcreteType (dependentType)) {
238+ if (genericSig->isValidTypeParameter (dependentType) &&
239+ genericSig->isConcreteType (dependentType)) {
239240 return conformedProtocol->getModuleContext ()->lookupConformance (
240241 conformingReplacementType, conformedProtocol,
241242 /* allowMissing=*/ true );
0 commit comments