File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1107,6 +1107,24 @@ static bool debugConstraintSolverForTarget(
1107
1107
return startBound != endBound;
1108
1108
}
1109
1109
1110
+ // / If we aren't certain that we've emitted a diagnostic, emit a fallback
1111
+ // / diagnostic.
1112
+ static void maybeProduceFallbackDiagnostic (
1113
+ ConstraintSystem &cs, SolutionApplicationTarget target) {
1114
+ if (cs.Options .contains (ConstraintSystemFlags::SubExpressionDiagnostics) ||
1115
+ cs.Options .contains (ConstraintSystemFlags::SuppressDiagnostics))
1116
+ return ;
1117
+
1118
+ // Before producing fatal error here, let's check if there are any "error"
1119
+ // diagnostics already emitted or waiting to be emitted. Because they are
1120
+ // a better indication of the problem.
1121
+ ASTContext &ctx = cs.getASTContext ();
1122
+ if (ctx.Diags .hadAnyError () || ctx.hasDelayedConformanceErrors ())
1123
+ return ;
1124
+
1125
+ ctx.Diags .diagnose (target.getLoc (), diag::failed_to_produce_diagnostic);
1126
+ }
1127
+
1110
1128
Optional<std::vector<Solution>> ConstraintSystem::solve (
1111
1129
SolutionApplicationTarget &target,
1112
1130
ExprTypeCheckListener *listener,
@@ -1152,6 +1170,7 @@ Optional<std::vector<Solution>> ConstraintSystem::solve(
1152
1170
}
1153
1171
1154
1172
case SolutionResult::Error:
1173
+ maybeProduceFallbackDiagnostic (*this , target);
1155
1174
return None;
1156
1175
1157
1176
case SolutionResult::TooComplex:
You can’t perform that action at this time.
0 commit comments