@@ -2644,6 +2644,8 @@ bool AssociatedTypeInference::simplifyCurrentTypeWitnesses() {
2644
2644
anyChanged = false ;
2645
2645
anyUnsubstituted = false ;
2646
2646
2647
+ LLVM_DEBUG (llvm::dbgs () << " Simplifying type witnesses -- iteration " << iterations << " \n " );
2648
+
2647
2649
if (++iterations > 100 ) {
2648
2650
llvm::errs () << " Too many iterations in simplifyCurrentTypeWitnesses()\n " ;
2649
2651
@@ -2679,6 +2681,10 @@ bool AssociatedTypeInference::simplifyCurrentTypeWitnesses() {
2679
2681
if (!typeWitness->hasTypeParameter ())
2680
2682
continue ;
2681
2683
2684
+ LLVM_DEBUG (llvm::dbgs () << " Attempting to simplify witness for "
2685
+ << assocType->getName ()
2686
+ << " : " << typeWitness << " \n " ;);
2687
+
2682
2688
auto simplified = typeWitness.transformRec (
2683
2689
[&](TypeBase *type) -> std::optional<Type> {
2684
2690
// Skip.
@@ -2807,10 +2813,16 @@ AssociatedTypeInference::getSubstOptionsWithCurrentTypeWitnesses() {
2807
2813
return nullptr ;
2808
2814
}
2809
2815
2810
- Type type = self->typeWitnesses .begin (assocType)->first ;
2816
+ auto found = self->typeWitnesses .begin (assocType);
2817
+ if (found == self->typeWitnesses .end ()) {
2818
+ // Invalid code.
2819
+ return ErrorType::get (thisProto->getASTContext ()).getPointer ();
2820
+ }
2821
+
2822
+ Type type = found->first ;
2811
2823
if (type->hasTypeParameter ()) {
2812
2824
// Not fully substituted yet.
2813
- return ErrorType::get (type ->getASTContext ()).getPointer ();
2825
+ return ErrorType::get (thisProto ->getASTContext ()).getPointer ();
2814
2826
}
2815
2827
2816
2828
return type->mapTypeOutOfContext ().getPointer ();
0 commit comments