@@ -30,13 +30,8 @@ ComponentStep::Scope::Scope(ComponentStep &component)
30
30
: CS(component.CS), Component(component) {
31
31
TypeVars = std::move (CS.TypeVariables );
32
32
33
- for (auto *typeVar : component.TypeVars ) {
34
- // Include type variables that either belong to this
35
- // component or have been bound.
36
- if (component.TypeVars .count (typeVar) > 0 ||
37
- typeVar->getImpl ().getFixedType (nullptr ))
38
- CS.TypeVariables .push_back (typeVar);
39
- }
33
+ for (auto *typeVar : component.TypeVars )
34
+ CS.TypeVariables .push_back (typeVar);
40
35
41
36
auto &workList = CS.InactiveConstraints ;
42
37
workList.splice (workList.end (), *component.Constraints );
@@ -132,21 +127,22 @@ void SplitterStep::computeFollowupSteps(
132
127
}
133
128
134
129
// Map type variables and constraints into appropriate steps.
130
+ llvm::DenseMap<TypeVariableType *, unsigned > typeVarComponent;
135
131
llvm::DenseMap<Constraint *, unsigned > constraintComponent;
136
132
for (unsigned i = 0 , n = typeVars.size (); i != n; ++i) {
137
133
auto *typeVar = typeVars[i];
138
- auto *component = componentSteps[components[i]];
134
+ // Record the component of this type variable.
135
+ typeVarComponent[typeVar] = components[i];
139
136
140
- component->record (typeVar);
141
137
for (auto *constraint : CG[typeVar].getConstraints ())
142
138
constraintComponent[constraint] = components[i];
143
139
}
144
140
145
141
// Add the orphaned components to the mapping from constraints to components.
146
- unsigned firstOrphanedConstraint =
142
+ unsigned firstOrphanedComponent =
147
143
numComponents - CG.getOrphanedConstraints ().size ();
148
144
{
149
- unsigned component = firstOrphanedConstraint ;
145
+ unsigned component = firstOrphanedComponent ;
150
146
for (auto *constraint : CG.getOrphanedConstraints ()) {
151
147
// Register this orphan constraint both as associated with
152
148
// a given component as a regular constrant, as well as an
@@ -157,6 +153,22 @@ void SplitterStep::computeFollowupSteps(
157
153
}
158
154
}
159
155
156
+ for (auto *typeVar : CS.TypeVariables ) {
157
+ auto known = typeVarComponent.find (typeVar);
158
+ // If current type variable is associated with
159
+ // a certain component step, record it as being so.
160
+ if (known != typeVarComponent.end ()) {
161
+ componentSteps[known->second ]->record (typeVar);
162
+ continue ;
163
+ }
164
+
165
+ // Otherwise, associate it with all of the component steps,
166
+ // expect for components with orphaned constraints, they are
167
+ // not supposed to have any type variables.
168
+ for (unsigned i = 0 ; i != firstOrphanedComponent; ++i)
169
+ componentSteps[i]->record (typeVar);
170
+ }
171
+
160
172
// Transfer all of the constraints from the work list to
161
173
// the appropriate component.
162
174
auto &workList = CS.InactiveConstraints ;
0 commit comments