@@ -301,6 +301,11 @@ struct PotentialBindings {
301301 Constraint *constraint);
302302
303303 void reset ();
304+
305+ void dump (ConstraintSystem &CS,
306+ TypeVariableType *TypeVar,
307+ llvm::raw_ostream &out,
308+ unsigned indent) const ;
304309};
305310
306311
@@ -567,64 +572,27 @@ class BindingSet {
567572 // /
568573 // / \param inferredBindings The set of all bindings inferred for type
569574 // / variables in the workset.
570- void inferTransitiveBindings (
571- const llvm::SmallDenseMap<TypeVariableType *, BindingSet>
572- &inferredBindings);
575+ void inferTransitiveBindings ();
573576
574577 // / Detect subtype, conversion or equivalence relationship
575578 // / between two type variables and attempt to propagate protocol
576579 // / requirements down the subtype or equivalence chain.
577- void inferTransitiveProtocolRequirements (
578- llvm::SmallDenseMap<TypeVariableType *, BindingSet> &inferredBindings);
580+ void inferTransitiveProtocolRequirements ();
579581
580582 // / Finalize binding computation for this type variable by
581583 // / inferring bindings from context e.g. transitive bindings.
582584 // /
583585 // / \returns true if finalization successful (which makes binding set viable),
584586 // / and false otherwise.
585- bool finalize (
586- llvm::SmallDenseMap<TypeVariableType *, BindingSet> &inferredBindings);
587+ bool finalize (bool transitive);
587588
588589 static BindingScore formBindingScore (const BindingSet &b);
589590
590- // / Compare two sets of bindings, where \c x < y indicates that
591- // / \c x is a better set of bindings that \c y.
592- friend bool operator <(const BindingSet &x, const BindingSet &y) {
593- auto xScore = formBindingScore (x);
594- auto yScore = formBindingScore (y);
595-
596- if (xScore < yScore)
597- return true ;
598-
599- if (yScore < xScore)
600- return false ;
601-
602- auto xDefaults = x.getNumViableDefaultableBindings ();
603- auto yDefaults = y.getNumViableDefaultableBindings ();
604-
605- // If there is a difference in number of default types,
606- // prioritize bindings with fewer of them.
607- if (xDefaults != yDefaults)
608- return xDefaults < yDefaults;
609-
610- // If neither type variable is a "hole" let's check whether
611- // there is a subtype relationship between them and prefer
612- // type variable which represents superclass first in order
613- // for "subtype" type variable to attempt more bindings later.
614- // This is required because algorithm can't currently infer
615- // bindings for subtype transitively through superclass ones.
616- if (!(std::get<0 >(xScore) && std::get<0 >(yScore))) {
617- if (x.Info .isSubtypeOf (y.getTypeVariable ()))
618- return false ;
619-
620- if (y.Info .isSubtypeOf (x.getTypeVariable ()))
621- return true ;
622- }
591+ bool operator ==(const BindingSet &other);
623592
624- // As a last resort, let's check if the bindings are
625- // potentially incomplete, and if so, let's de-prioritize them.
626- return x.isPotentiallyIncomplete () < y.isPotentiallyIncomplete ();
627- }
593+ // / Compare two sets of bindings, where \c this < other indicates that
594+ // / \c this is a better set of bindings that \c other.
595+ bool operator <(const BindingSet &other);
628596
629597 void dump (llvm::raw_ostream &out, unsigned indent) const ;
630598
0 commit comments