Skip to content

Commit f8fd197

Browse files
committed
[Constraint solver] Remove ExprTypeCheckListener::applySolutionFailed.
We don’t need this fallback path.
1 parent 754afff commit f8fd197

File tree

2 files changed

+0
-48
lines changed

2 files changed

+0
-48
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,9 +2035,6 @@ Expr *ExprTypeCheckListener::appliedSolution(Solution &solution, Expr *expr) {
20352035
return expr;
20362036
}
20372037

2038-
void ExprTypeCheckListener::applySolutionFailed(Solution &solution,
2039-
Expr *expr) {}
2040-
20412038
void ParentConditionalConformance::diagnoseConformanceStack(
20422039
DiagnosticEngine &diags, SourceLoc loc,
20432040
ArrayRef<ParentConditionalConformance> conformances) {
@@ -2095,45 +2092,6 @@ class FallbackDiagnosticListener : public ExprTypeCheckListener {
20952092
Expr *appliedSolution(Solution &solution, Expr *expr) override {
20962093
return BaseListener ? BaseListener->appliedSolution(solution, expr) : expr;
20972094
}
2098-
2099-
void applySolutionFailed(Solution &solution, Expr *expr) override {
2100-
if (BaseListener)
2101-
BaseListener->applySolutionFailed(solution, expr);
2102-
2103-
if (hadAnyErrors())
2104-
return;
2105-
2106-
// If solution involves invalid or incomplete conformances that's
2107-
// a probable cause of failure to apply it without producing an error,
2108-
// which is going to be diagnosed later, so let's not produce
2109-
// fallback diagnostic in this case.
2110-
if (llvm::any_of(
2111-
solution.Conformances,
2112-
[](const std::pair<ConstraintLocator *, ProtocolConformanceRef>
2113-
&conformance) -> bool {
2114-
auto &ref = conformance.second;
2115-
return ref.isConcrete() && ref.getConcrete()->isInvalid();
2116-
}))
2117-
return;
2118-
2119-
maybeProduceFallbackDiagnostic(expr);
2120-
}
2121-
2122-
private:
2123-
bool hadAnyErrors() const { return Context.Diags.hadAnyError(); }
2124-
2125-
void maybeProduceFallbackDiagnostic(Expr *expr) const {
2126-
if (Options.contains(TypeCheckExprFlags::SubExpressionDiagnostics) ||
2127-
DiagnosticSuppression::isEnabled(Context.Diags))
2128-
return;
2129-
2130-
// Before producing fatal error here, let's check if there are any "error"
2131-
// diagnostics already emitted or waiting to be emitted. Because they are
2132-
// a better indication of the problem.
2133-
if (!(hadAnyErrors() || Context.hasDelayedConformanceErrors()))
2134-
Context.Diags.diagnose(expr->getLoc(),
2135-
diag::failed_to_produce_diagnostic);
2136-
}
21372095
};
21382096

21392097
#pragma mark High-level entry points
@@ -2259,8 +2217,6 @@ Type TypeChecker::typeCheckExpressionImpl(Expr *&expr, DeclContext *dc,
22592217
options.contains(TypeCheckExprFlags::SubExpressionDiagnostics);
22602218
auto resultTarget = cs.applySolution(solution, target, performingDiagnostics);
22612219
if (!resultTarget) {
2262-
listener.applySolutionFailed(solution, expr);
2263-
22642220
// Failure already diagnosed, above, as part of applying the solution.
22652221
return Type();
22662222
}

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@ class ExprTypeCheckListener {
320320
/// failure.
321321
virtual Expr *appliedSolution(constraints::Solution &solution,
322322
Expr *expr);
323-
324-
/// Callback invoked if application of chosen solution to
325-
/// expression has failed.
326-
virtual void applySolutionFailed(constraints::Solution &solution, Expr *expr);
327323
};
328324

329325
/// A conditional conformance that implied some other requirements. That is, \c

0 commit comments

Comments
 (0)