Skip to content

Commit 186589b

Browse files
committed
Sema: Remove SolverTrail::Change::introducedToInference()
1 parent c46ee87 commit 186589b

File tree

5 files changed

+0
-75
lines changed

5 files changed

+0
-75
lines changed

include/swift/Sema/CSTrail.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class SolverTrail {
4747
ExtendedEquivalenceClass,
4848
/// Added a new edge in the constraint graph.
4949
RelatedTypeVariables,
50-
/// Introduced a type variable's fixed type to inference.
51-
IntroducedToInference,
5250
/// Inferred potential bindings from a constraint.
5351
InferredBindings,
5452
/// Retracted potential bindings from a constraint.
@@ -93,14 +91,6 @@ class SolverTrail {
9391
TypeVariableType *OtherTypeVar;
9492
} Relation;
9593

96-
struct {
97-
/// The type variable being bound to a fixed type.
98-
TypeVariableType *TypeVar;
99-
100-
/// The fixed type to which the type variable was bound.
101-
TypeBase *FixedType;
102-
} Binding;
103-
10494
struct {
10595
/// The type variable being updated.
10696
TypeVariableType *TypeVar;
@@ -133,9 +123,6 @@ class SolverTrail {
133123
static Change relatedTypeVariables(TypeVariableType *typeVar,
134124
TypeVariableType *otherTypeVar);
135125

136-
/// Create a change that introduced a type variable to inference.
137-
static Change introducedToInference(TypeVariableType *typeVar, Type fixed);
138-
139126
/// Create a change that inferred bindings from a constraint.
140127
static Change inferredBindings(TypeVariableType *typeVar,
141128
Constraint *constraint);

include/swift/Sema/ConstraintGraph.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ class ConstraintGraphNode {
153153
/// type variable has been bound to a valid type and solver can make progress.
154154
void introduceToInference(Type fixedType);
155155

156-
/// Opposite of \c introduceToInference(Type)
157-
void retractFromInference(Type fixedType);
158-
159156
/// Drop all previously collected bindings and re-infer based on the
160157
/// current set constraints associated with this equivalence class.
161158
void resetBindingSet();
@@ -446,11 +443,6 @@ class ConstraintGraph {
446443
/// Note that this it only meant to be called by SolverTrail::Change::undo().
447444
void retractBindings(TypeVariableType *typeVar, Constraint *constraint);
448445

449-
/// Retract the given type variable from inference.
450-
///
451-
/// Note that this it only meant to be called by SolverTrail::Change::undo().
452-
void retractFromInference(TypeVariableType *typeVar, Type fixedType);
453-
454446
/// Perform edge contraction on the constraint graph, merging equivalence
455447
/// classes until a fixed point is reached.
456448
bool contractEdges();

lib/Sema/CSTrail.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ SolverTrail::Change::relatedTypeVariables(TypeVariableType *typeVar,
8989
return result;
9090
}
9191

92-
SolverTrail::Change
93-
SolverTrail::Change::introducedToInference(TypeVariableType *typeVar,
94-
Type fixed) {
95-
Change result;
96-
result.Kind = ChangeKind::IntroducedToInference;
97-
result.Binding.TypeVar = typeVar;
98-
result.Binding.FixedType = fixed.getPointer();
99-
return result;
100-
}
101-
10292
SolverTrail::Change
10393
SolverTrail::Change::inferredBindings(TypeVariableType *typeVar,
10494
Constraint *constraint) {
@@ -158,10 +148,6 @@ void SolverTrail::Change::undo(ConstraintSystem &cs) const {
158148
cg.unrelateTypeVariables(Relation.TypeVar, Relation.OtherTypeVar);
159149
break;
160150

161-
case ChangeKind::IntroducedToInference:
162-
cg.retractFromInference(Binding.TypeVar, Binding.FixedType);
163-
break;
164-
165151
case ChangeKind::InferredBindings:
166152
cg.retractBindings(TheConstraint.TypeVar, TheConstraint.Constraint);
167153
break;
@@ -225,14 +211,6 @@ void SolverTrail::Change::dump(llvm::raw_ostream &out,
225211
out << ")\n";
226212
break;
227213

228-
case ChangeKind::IntroducedToInference:
229-
out << "(introduced type variable ";
230-
Binding.TypeVar->print(out, PO);
231-
out << " with fixed type ";
232-
Binding.FixedType->print(out, PO);
233-
out << " to inference)\n";
234-
break;
235-
236214
case ChangeKind::InferredBindings:
237215
out << "(inferred bindings from ";
238216
TheConstraint.Constraint->print(out, &cs.getASTContext().SourceMgr,

lib/Sema/ConstraintGraph.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ ConstraintGraph::lookupNode(TypeVariableType *typeVar) {
9292
if (typeVar != typeVarRep)
9393
mergeNodes(typeVar, typeVarRep);
9494
else if (auto fixed = CS.getFixedType(typeVarRep)) {
95-
// FIXME: This is totally the wrong place to do it. We should do this in
96-
// introduceToInference().
97-
if (CS.isRecordingChanges())
98-
CS.recordChange(SolverTrail::Change::introducedToInference(typeVar, fixed));
99-
10095
// Bind the type variable.
10196
bindTypeVariable(typeVar, fixed);
10297
}
@@ -381,24 +376,6 @@ void ConstraintGraphNode::introduceToInference(Type fixedType) {
381376
}
382377
}
383378

384-
void ConstraintGraphNode::retractFromInference(Type fixedType) {
385-
// Notify referencing variables (just like in bound case) that this
386-
// type variable has been modified.
387-
notifyReferencingVars();
388-
389-
SmallPtrSet<TypeVariableType *, 4> referencedVars;
390-
fixedType->getTypeVariables(referencedVars);
391-
392-
// TODO: This might be an overkill but it's (currently)
393-
// the simplest way to reliably ensure that all of the
394-
// no longer related constraints have been retracted.
395-
for (auto *referencedVar : referencedVars) {
396-
auto &node = CG[referencedVar];
397-
if (node.forRepresentativeVar())
398-
node.resetBindingSet();
399-
}
400-
}
401-
402379
void ConstraintGraphNode::resetBindingSet() {
403380
assert(forRepresentativeVar());
404381

@@ -585,10 +562,6 @@ void ConstraintGraph::unrelateTypeVariables(TypeVariableType *typeVar,
585562
node.removeReference(otherTypeVar);
586563
}
587564

588-
void ConstraintGraph::retractFromInference(TypeVariableType *typeVar, Type fixed) {
589-
(*this)[typeVar].retractFromInference(fixed);
590-
}
591-
592565
void ConstraintGraph::inferBindings(TypeVariableType *typeVar,
593566
Constraint *constraint) {
594567
(*this)[typeVar].getCurrentBindings().infer(constraint);

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,6 @@ void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
239239
}
240240
}
241241

242-
// FIXME: This is totally the wrong place to do it. We should do this in
243-
// introduceToInference().
244-
if (isRecordingChanges())
245-
recordChange(SolverTrail::Change::introducedToInference(typeVar, type));
246-
247242
// Notify the constraint graph.
248243
CG.bindTypeVariable(typeVar, type);
249244

0 commit comments

Comments
 (0)