@@ -4744,9 +4744,6 @@ class ConstraintSystem {
47444744 // / Whether this type variable has literal bindings.
47454745 LiteralBindingKind LiteralBinding = LiteralBindingKind::None;
47464746
4747- // / Whether this type variable is only bound above by existential types.
4748- bool SubtypeOfExistentialType = false ;
4749-
47504747 // / Tracks the position of the last known supertype in the group.
47514748 Optional<unsigned > lastSupertypeIndex;
47524749
@@ -4764,6 +4761,19 @@ class ConstraintSystem {
47644761 // / Determine whether the set of bindings is non-empty.
47654762 explicit operator bool () const { return !Bindings.empty (); }
47664763
4764+ // / Determine if the bindings only constrain the type variable from above
4765+ // / with an existential type; such a binding is not very helpful because
4766+ // / it's impossible to enumerate the existential type's subtypes.
4767+ bool isSubtypeOfExistentialType () const {
4768+ if (Bindings.empty ())
4769+ return false ;
4770+
4771+ return llvm::all_of (Bindings, [](const PotentialBinding &binding) {
4772+ return binding.BindingType ->isExistentialType () &&
4773+ binding.Kind == AllowedBindingKind::Subtypes;
4774+ });
4775+ }
4776+
47674777 unsigned getNumDefaultableBindings () const {
47684778 return llvm::count_if (Bindings, [](const PotentialBinding &binding) {
47694779 return binding.isDefaultableBinding ();
@@ -4777,7 +4787,7 @@ class ConstraintSystem {
47774787 return std::make_tuple (b.IsHole ,
47784788 !hasNoDefaultableBindings,
47794789 b.FullyBound ,
4780- b.SubtypeOfExistentialType ,
4790+ b.isSubtypeOfExistentialType () ,
47814791 b.InvolvesTypeVariables ,
47824792 static_cast <unsigned char >(b.LiteralBinding ),
47834793 -(b.Bindings .size () - numDefaults));
@@ -4925,7 +4935,7 @@ class ConstraintSystem {
49254935 out << " potentially_incomplete " ;
49264936 if (FullyBound)
49274937 out << " fully_bound " ;
4928- if (SubtypeOfExistentialType )
4938+ if (isSubtypeOfExistentialType () )
49294939 out << " subtype_of_existential " ;
49304940 if (LiteralBinding != LiteralBindingKind::None)
49314941 out << " literal=" << static_cast <int >(LiteralBinding) << " " ;
0 commit comments