@@ -1068,10 +1068,7 @@ ConstraintGraph::computeConnectedComponents(
1068
1068
// / edge in the graph.
1069
1069
static bool shouldContractEdge (ConstraintKind kind) {
1070
1070
switch (kind) {
1071
- case ConstraintKind::Bind:
1072
1071
case ConstraintKind::BindParam:
1073
- case ConstraintKind::BindToPointerType:
1074
- case ConstraintKind::Equal:
1075
1072
return true ;
1076
1073
1077
1074
default :
@@ -1103,8 +1100,6 @@ bool ConstraintGraph::contractEdges() {
1103
1100
if (!(tyvar1 && tyvar2))
1104
1101
continue ;
1105
1102
1106
- auto isParamBindingConstraint = kind == ConstraintKind::BindParam;
1107
-
1108
1103
// If the argument is allowed to bind to `inout`, in general,
1109
1104
// it's invalid to contract the edge between argument and parameter,
1110
1105
// but if we can prove that there are no possible bindings
@@ -1114,7 +1109,7 @@ bool ConstraintGraph::contractEdges() {
1114
1109
// Such action is valid because argument type variable can
1115
1110
// only get its bindings from related overload, which gives
1116
1111
// us enough information to decided on l-valueness.
1117
- if (isParamBindingConstraint && tyvar1->getImpl ().canBindToInOut ()) {
1112
+ if (tyvar1->getImpl ().canBindToInOut ()) {
1118
1113
bool isNotContractable = true ;
1119
1114
if (auto bindings = CS.inferBindingsFor (tyvar1)) {
1120
1115
// Holes can't be contracted.
@@ -1146,26 +1141,21 @@ bool ConstraintGraph::contractEdges() {
1146
1141
auto rep1 = CS.getRepresentative (tyvar1);
1147
1142
auto rep2 = CS.getRepresentative (tyvar2);
1148
1143
1149
- if (((rep1->getImpl ().canBindToLValue () ==
1150
- rep2->getImpl ().canBindToLValue ()) ||
1151
- // Allow l-value contractions when binding parameter types.
1152
- isParamBindingConstraint)) {
1153
- if (CS.isDebugMode ()) {
1154
- auto &log = llvm::errs ();
1155
- if (CS.solverState )
1156
- log.indent (CS.solverState ->depth * 2 );
1157
-
1158
- log << " Contracting constraint " ;
1159
- constraint->print (log, &CS.getASTContext ().SourceMgr );
1160
- log << " \n " ;
1161
- }
1144
+ if (CS.isDebugMode ()) {
1145
+ auto &log = llvm::errs ();
1146
+ if (CS.solverState )
1147
+ log.indent (CS.solverState ->depth * 2 );
1162
1148
1163
- // Merge the edges and retire the constraint.
1164
- CS.retireConstraint (constraint);
1165
- if (rep1 != rep2)
1166
- CS.mergeEquivalenceClasses (rep1, rep2, /* updateWorkList*/ false );
1167
- didContractEdges = true ;
1149
+ log << " Contracting constraint " ;
1150
+ constraint->print (log, &CS.getASTContext ().SourceMgr );
1151
+ log << " \n " ;
1168
1152
}
1153
+
1154
+ // Merge the edges and retire the constraint.
1155
+ CS.retireConstraint (constraint);
1156
+ if (rep1 != rep2)
1157
+ CS.mergeEquivalenceClasses (rep1, rep2, /* updateWorkList*/ false );
1158
+ didContractEdges = true ;
1169
1159
}
1170
1160
return didContractEdges;
1171
1161
}
0 commit comments