@@ -4773,9 +4773,6 @@ class ConstraintSystem {
4773
4773
4774
4774
ASTNode AssociatedCodeCompletionToken = ASTNode();
4775
4775
4776
- // / Whether this type variable has literal bindings.
4777
- LiteralBindingKind LiteralBinding = LiteralBindingKind::None;
4778
-
4779
4776
// / A set of all not-yet-resolved type variables this type variable
4780
4777
// / is a subtype of, supertype of or is equivalent to. This is used
4781
4778
// / to determine ordering inside of a chain of subtypes to help infer
@@ -4901,7 +4898,7 @@ class ConstraintSystem {
4901
4898
b.isDelayed (),
4902
4899
b.isSubtypeOfExistentialType (),
4903
4900
b.involvesTypeVariables (),
4904
- static_cast <unsigned char >(b.LiteralBinding ),
4901
+ static_cast <unsigned char >(b.getLiteralKind () ),
4905
4902
-numNonDefaultableBindings);
4906
4903
}
4907
4904
@@ -4945,23 +4942,33 @@ class ConstraintSystem {
4945
4942
return x.isPotentiallyIncomplete () < y.isPotentiallyIncomplete ();
4946
4943
}
4947
4944
4948
- void foundLiteralBinding (ProtocolDecl *proto) {
4949
- switch (*proto->getKnownProtocolKind ()) {
4950
- case KnownProtocolKind::ExpressibleByDictionaryLiteral:
4951
- case KnownProtocolKind::ExpressibleByArrayLiteral:
4952
- case KnownProtocolKind::ExpressibleByStringInterpolation:
4953
- LiteralBinding = LiteralBindingKind::Collection;
4954
- break ;
4945
+ LiteralBindingKind getLiteralKind () const {
4946
+ LiteralBindingKind kind = LiteralBindingKind::None;
4955
4947
4956
- case KnownProtocolKind::ExpressibleByFloatLiteral:
4957
- LiteralBinding = LiteralBindingKind::Float;
4958
- break ;
4948
+ for (const auto &binding : Bindings) {
4949
+ auto *proto = binding.getDefaultedLiteralProtocol ();
4950
+ if (!proto)
4951
+ continue ;
4959
4952
4960
- default :
4961
- if (LiteralBinding != LiteralBindingKind::Collection)
4962
- LiteralBinding = LiteralBindingKind::Atom;
4963
- break ;
4953
+ switch (*proto->getKnownProtocolKind ()) {
4954
+ case KnownProtocolKind::ExpressibleByDictionaryLiteral:
4955
+ case KnownProtocolKind::ExpressibleByArrayLiteral:
4956
+ case KnownProtocolKind::ExpressibleByStringInterpolation:
4957
+ kind = LiteralBindingKind::Collection;
4958
+ break ;
4959
+
4960
+ case KnownProtocolKind::ExpressibleByFloatLiteral:
4961
+ kind = LiteralBindingKind::Float;
4962
+ break ;
4963
+
4964
+ default :
4965
+ if (kind != LiteralBindingKind::Collection)
4966
+ kind = LiteralBindingKind::Atom;
4967
+ break ;
4968
+ }
4964
4969
}
4970
+
4971
+ return kind;
4965
4972
}
4966
4973
4967
4974
void addDefault (Constraint *constraint);
@@ -5055,8 +5062,9 @@ class ConstraintSystem {
5055
5062
out << " delayed " ;
5056
5063
if (isSubtypeOfExistentialType ())
5057
5064
out << " subtype_of_existential " ;
5058
- if (LiteralBinding != LiteralBindingKind::None)
5059
- out << " literal=" << static_cast <int >(LiteralBinding) << " " ;
5065
+ auto literalKind = getLiteralKind ();
5066
+ if (literalKind != LiteralBindingKind::None)
5067
+ out << " literal=" << static_cast <int >(literalKind) << " " ;
5060
5068
if (involvesTypeVariables ())
5061
5069
out << " involves_type_vars " ;
5062
5070
0 commit comments