@@ -657,6 +657,7 @@ void SubstitutionMap::verify() const {
657
657
if (req.getKind () != RequirementKind::Conformance)
658
658
continue ;
659
659
660
+ SWIFT_DEFER { ++conformanceIndex; };
660
661
auto substType = req.getFirstType ().subst (*this );
661
662
if (substType->isTypeParameter () ||
662
663
substType->is <ArchetypeType>() ||
@@ -677,15 +678,44 @@ void SubstitutionMap::verify() const {
677
678
llvm::dbgs () << " SubstitutionMap:\n " ;
678
679
dump (llvm::dbgs ());
679
680
llvm::dbgs () << " \n " ;
681
+ llvm::dbgs () << " Requirement:\n " ;
682
+ req.dump (llvm::dbgs ());
683
+ llvm::dbgs () << " \n " ;
680
684
}
681
685
assert (conformance.isConcrete () && " Conformance should be concrete" );
686
+
687
+ if (substType->is <UnboundGenericType>())
688
+ continue ;
689
+
690
+ auto conformanceTy = conformance.getConcrete ()->getType ();
691
+ if (conformanceTy->hasTypeParameter ()
692
+ && !substType->hasTypeParameter ()) {
693
+ conformanceTy = conformance.getConcrete ()->getDeclContext ()
694
+ ->mapTypeIntoContext (conformanceTy);
695
+ }
696
+
697
+ if (!substType->isEqual (conformanceTy)) {
698
+ llvm::dbgs () << " Conformance must match concrete replacement type:\n " ;
699
+ substType->dump (llvm::dbgs ());
700
+ llvm::dbgs () << " Conformance type:\n " ;
701
+ conformance.getConcrete ()->getType ()->dump (llvm::dbgs ());
702
+ llvm::dbgs () << " Conformance:\n " ;
703
+ conformance.dump (llvm::dbgs ());
704
+ llvm::dbgs () << " \n " ;
705
+ llvm::dbgs () << " SubstitutionMap:\n " ;
706
+ dump (llvm::dbgs ());
707
+ llvm::dbgs () << " \n " ;
708
+ llvm::dbgs () << " Requirement:\n " ;
709
+ req.dump (llvm::dbgs ());
710
+ llvm::dbgs () << " \n " ;
711
+ }
712
+ assert (substType->isEqual (conformanceTy)
713
+ && " conformance should match corresponding type" );
682
714
683
715
if (substType->isExistentialType ()) {
684
716
assert (isa<SelfProtocolConformance>(conformance.getConcrete ()) &&
685
717
" Existential type cannot have normal conformance" );
686
718
}
687
-
688
- ++conformanceIndex;
689
719
}
690
720
#endif
691
721
}
0 commit comments