@@ -50,24 +50,26 @@ static std::optional<Type> checkTypeOfBinding(TypeVariableType *typeVar,
5050BindingSet::BindingSet (ConstraintSystem &CS, TypeVariableType *TypeVar,
5151 const PotentialBindings &info)
5252 : CS(CS), TypeVar(TypeVar), Info(info) {
53+
5354 for (const auto &binding : info.Bindings )
5455 addBinding (binding, /* isTransitive=*/ false );
5556
5657 for (auto *constraint : info.Constraints ) {
5758 switch (constraint->getKind ()) {
58- case ConstraintKind::ConformsTo: {
59+ case ConstraintKind::ConformsTo:
5960 if (constraint->getSecondType ()->is <ProtocolType>())
6061 Protocols.push_back (constraint);
6162 break ;
62- }
63+
64+ case ConstraintKind::LiteralConformsTo:
65+ addLiteralRequirement (constraint);
66+ break ;
67+
6368 default :
6469 break ;
6570 }
6671 }
6772
68- for (auto *literal : info.Literals )
69- addLiteralRequirement (literal);
70-
7173 for (auto *constraint : info.Defaults )
7274 addDefault (constraint);
7375
@@ -1311,10 +1313,6 @@ void PotentialBindings::addPotentialBinding(TypeVariableType *TypeVar,
13111313 Bindings.push_back (std::move (binding));
13121314}
13131315
1314- void PotentialBindings::addLiteral (Constraint *constraint) {
1315- Literals.insert (constraint);
1316- }
1317-
13181316bool BindingSet::isViable (PotentialBinding &binding, bool isTransitive) {
13191317 // Prevent against checking against the same opened nominal type
13201318 // over and over again. Doing so means redundant work in the best
@@ -1969,6 +1967,7 @@ void PotentialBindings::infer(ConstraintSystem &CS,
19691967 case ConstraintKind::SameShape:
19701968 case ConstraintKind::MaterializePackExpansion:
19711969 case ConstraintKind::ConformsTo:
1970+ case ConstraintKind::LiteralConformsTo:
19721971 // Constraints from which we can't do anything.
19731972 break ;
19741973
@@ -2009,13 +2008,6 @@ void PotentialBindings::infer(ConstraintSystem &CS,
20092008 DelayedBy.push_back (constraint);
20102009 break ;
20112010
2012- case ConstraintKind::LiteralConformsTo: {
2013- // Record constraint where protocol requirement originated
2014- // this is useful to use for the binding later.
2015- addLiteral (constraint);
2016- break ;
2017- }
2018-
20192011 case ConstraintKind::ApplicableFunction:
20202012 case ConstraintKind::DynamicCallableApplicableFunction: {
20212013 auto overloadTy = constraint->getSecondType ();
@@ -2090,7 +2082,6 @@ void PotentialBindings::retract(ConstraintSystem &CS,
20902082
20912083 LLVM_DEBUG (
20922084 llvm::dbgs () << Constraints.size () << " " << Bindings.size () << " "
2093- << Literals.size () << " "
20942085 << AdjacentVars.size () << " " << DelayedBy.size () << " "
20952086 << SubtypeOf.size () << " " << SupertypeOf.size () << " "
20962087 << EquivalentTo.size () << " \n " );
@@ -2103,10 +2094,6 @@ void PotentialBindings::retract(ConstraintSystem &CS,
21032094 Bindings.end ());
21042095
21052096 switch (constraint->getKind ()) {
2106- case ConstraintKind::LiteralConformsTo:
2107- Literals.erase (constraint);
2108- break ;
2109-
21102097 case ConstraintKind::Defaultable:
21112098 case ConstraintKind::FallbackType: {
21122099 Defaults.erase (constraint);
@@ -2150,7 +2137,6 @@ void PotentialBindings::reset() {
21502137 if (CONDITIONAL_ASSERT_enabled ()) {
21512138 ASSERT (Constraints.empty ());
21522139 ASSERT (Bindings.empty ());
2153- ASSERT (Literals.empty ());
21542140 ASSERT (Defaults.empty ());
21552141 ASSERT (DelayedBy.empty ());
21562142 ASSERT (AdjacentVars.empty ());
0 commit comments