@@ -4744,9 +4744,6 @@ class ConstraintSystem {
4744
4744
// / Whether this type variable has literal bindings.
4745
4745
LiteralBindingKind LiteralBinding = LiteralBindingKind::None;
4746
4746
4747
- // / Whether this type variable is only bound above by existential types.
4748
- bool SubtypeOfExistentialType = false ;
4749
-
4750
4747
// / Tracks the position of the last known supertype in the group.
4751
4748
Optional<unsigned > lastSupertypeIndex;
4752
4749
@@ -4764,6 +4761,19 @@ class ConstraintSystem {
4764
4761
// / Determine whether the set of bindings is non-empty.
4765
4762
explicit operator bool () const { return !Bindings.empty (); }
4766
4763
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
+
4767
4777
unsigned getNumDefaultableBindings () const {
4768
4778
return llvm::count_if (Bindings, [](const PotentialBinding &binding) {
4769
4779
return binding.isDefaultableBinding ();
@@ -4777,7 +4787,7 @@ class ConstraintSystem {
4777
4787
return std::make_tuple (b.IsHole ,
4778
4788
!hasNoDefaultableBindings,
4779
4789
b.FullyBound ,
4780
- b.SubtypeOfExistentialType ,
4790
+ b.isSubtypeOfExistentialType () ,
4781
4791
b.InvolvesTypeVariables ,
4782
4792
static_cast <unsigned char >(b.LiteralBinding ),
4783
4793
-(b.Bindings .size () - numDefaults));
@@ -4925,7 +4935,7 @@ class ConstraintSystem {
4925
4935
out << " potentially_incomplete " ;
4926
4936
if (FullyBound)
4927
4937
out << " fully_bound " ;
4928
- if (SubtypeOfExistentialType )
4938
+ if (isSubtypeOfExistentialType () )
4929
4939
out << " subtype_of_existential " ;
4930
4940
if (LiteralBinding != LiteralBindingKind::None)
4931
4941
out << " literal=" << static_cast <int >(LiteralBinding) << " " ;
0 commit comments