Skip to content

Commit 5685a45

Browse files
committed
AST: Tweak LookUpConformanceInSubstitutionMap
1 parent 970740b commit 5685a45

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
@@ -220,10 +220,6 @@ operator()(CanType dependentType, Type conformingReplacementType,
220220
ProtocolConformanceRef LookUpConformanceInSubstitutionMap::
221221
operator()(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

Comments
 (0)