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

@@ -883,11 +883,7 @@ public:
return Overload.Prepared;
}
void setPreparedOverload(PreparedOverload *preparedOverload) {
ASSERT(Kind == ConstraintKind::BindOverload);
ASSERT(!Overload.Prepared);
Overload.Prepared = preparedOverload;
}
void setPreparedOverload(PreparedOverload *preparedOverload);
FunctionType *getAppliedFunctionType() const {
assert(Kind == ConstraintKind::ApplicableFunction);

View File

@@ -4876,7 +4876,8 @@ public:
/// Build and allocate a prepared overload in the solver arena.
PreparedOverload *prepareOverload(OverloadChoice choice,
DeclContext *useDC,
ConstraintLocator *locator);
ConstraintLocator *locator,
bool forDiagnostics);
/// Populate the prepared overload with all type variables and constraints
/// that are to be introduced into the constraint system when this choice

View File

@@ -160,7 +160,11 @@ public:
private:
Type OpenedType;
Type ThrownErrorType;
size_t Count;
unsigned Count : 31;
/// A prepared overload for diagnostics is different than one without,
/// because of fixes and such.
unsigned ForDiagnostics : 1;
size_t numTrailingObjects(OverloadToken<Change>) const {
return Count;
@@ -168,9 +172,9 @@ private:
public:
PreparedOverload(Type openedType, Type thrownErrorType,
ArrayRef<Change> changes)
ArrayRef<Change> changes, bool forDiagnostics)
: OpenedType(openedType), ThrownErrorType(thrownErrorType),
Count(changes.size()) {
Count(changes.size()), ForDiagnostics(forDiagnostics) {
std::uninitialized_copy(changes.begin(), changes.end(),
getTrailingObjects());
}
@@ -183,6 +187,10 @@ public:
return ThrownErrorType;
}
bool wasForDiagnostics() const {
return ForDiagnostics;
}
ArrayRef<Change> getChanges() const { return getTrailingObjects(Count); }
};