Skip to content

Commit 0c01b62

Browse files
committed
[ConstraintSystem] Account for duplicate archetype bindings
in IsDeclRefinementOfRequest.
1 parent 7783f6b commit 0c01b62

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Sema/CSStep.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,16 @@ bool IsDeclRefinementOfRequest::evaluate(Evaluator &evaluator,
554554
substTypeB = substTypeB->substituteBindingsTo(substTypeA,
555555
[&](ArchetypeType *origType, CanType substType,
556556
ArchetypeType *, ArrayRef<ProtocolConformanceRef>) -> CanType {
557-
auto interfaceTy = origType->getInterfaceType()->getCanonicalType();
558-
substMap[interfaceTy->getAs<SubstitutableType>()] = substType;
557+
auto interfaceTy =
558+
origType->getInterfaceType()->getCanonicalType()->getAs<SubstitutableType>();
559+
560+
// Make sure any duplicate bindings are equal to the one already recorded.
561+
// Otherwise, the substition has conflicting generic arguments.
562+
auto bound = substMap.find(interfaceTy);
563+
if (bound != substMap.end() && !bound->second->isEqual(substType))
564+
return CanType();
565+
566+
substMap[interfaceTy] = substType;
559567
return substType;
560568
});
561569

0 commit comments

Comments
 (0)