Sema: Don't reuse PreparedOverload from normal type checking in salvage()

We want to re-prepare our overloads, since now they will contain fixes.
This commit is contained in:
Slava Pestov
2025-10-10 15:33:53 -04:00
parent 036db6fb08
commit a8d896ab8f
6 changed files with 50 additions and 19 deletions

View File

@@ -20,6 +20,7 @@
#include "swift/Basic/Compiler.h"
#include "swift/Sema/Constraint.h"
#include "swift/Sema/ConstraintSystem.h"
#include "swift/Sema/PreparedOverload.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -1142,3 +1143,18 @@ void *Constraint::operator new(size_t bytes, ConstraintSystem& cs,
size_t alignment) {
return ::operator new (bytes, cs, alignment);
}
// FIXME: Perhaps we should store the Constraint -> PreparedOverload mapping
// in a SolverStep or something? Mutating Constraint feels wrong.
void Constraint::setPreparedOverload(PreparedOverload *preparedOverload) {
ASSERT(Kind == ConstraintKind::BindOverload);
// We can only set a prepared overload at most once in normal
// type checking, and then once in salvage.
ASSERT(!Overload.Prepared ||
(!Overload.Prepared->wasForDiagnostics() &&
preparedOverload->wasForDiagnostics()));
Overload.Prepared = preparedOverload;
}