@@ -7761,21 +7761,20 @@ Expr *ConstraintSystem::coerceToRValue(Expr *expr) {
7761
7761
// / Emit the fixes computed as part of the solution, returning true if we were
7762
7762
// / able to emit an error message, or false if none of the fixits worked out.
7763
7763
bool ConstraintSystem::applySolutionFixes (Expr *E, const Solution &solution) {
7764
- llvm::SmallDenseMap<Expr *,
7765
- SmallVector<std::pair<Fix, ConstraintLocator *>, 4 >>
7764
+ llvm::SmallDenseMap<Expr *, SmallVector<const ConstraintFix *, 4 >>
7766
7765
fixesPerExpr;
7767
7766
7768
- for (const auto & fix : solution.Fixes )
7769
- fixesPerExpr[fix. second ->getAnchor ()].push_back (fix);
7767
+ for (auto * fix : solution.Fixes )
7768
+ fixesPerExpr[fix->getAnchor ()].push_back (fix);
7770
7769
7771
7770
auto diagnoseExprFailures = [&](Expr *expr) -> bool {
7772
7771
auto fixes = fixesPerExpr.find (expr);
7773
7772
if (fixes == fixesPerExpr.end ())
7774
7773
return false ;
7775
7774
7776
7775
bool diagnosed = false ;
7777
- for (auto & fix : fixes->second )
7778
- diagnosed |= applySolutionFix (E, solution, fix );
7776
+ for (const auto * fix : fixes->second )
7777
+ diagnosed |= fix-> diagnose (E, solution);
7779
7778
return diagnosed;
7780
7779
};
7781
7780
@@ -7792,86 +7791,6 @@ bool ConstraintSystem::applySolutionFixes(Expr *E, const Solution &solution) {
7792
7791
return diagnosed;
7793
7792
}
7794
7793
7795
- // / \brief Apply the specified Fix to this solution, producing a fix-it hint
7796
- // / diagnostic for it and returning true. If the fix-it hint turned out to be
7797
- // / bogus, this returns false and doesn't emit anything.
7798
- bool ConstraintSystem::applySolutionFix (
7799
- Expr *expr, const Solution &solution,
7800
- std::pair<Fix, ConstraintLocator *> &fix) {
7801
- // Some fixes need more information from the locator.
7802
- ConstraintLocator *locator = fix.second ;
7803
-
7804
- // In the case of us having applied a type member constraint against a
7805
- // synthesized type variable during diagnostic generation, we may not have
7806
- // a valid locator.
7807
- if (!locator)
7808
- return false ;
7809
-
7810
- switch (fix.first .getKind ()) {
7811
- case FixKind::ForceOptional: {
7812
- MissingOptionalUnwrapFailure failure (expr, solution, locator);
7813
- return failure.diagnose ();
7814
- }
7815
-
7816
- case FixKind::UnwrapOptionalBase: {
7817
- auto memberName = fix.first .getDeclNameArgument (*this );
7818
- bool resultIsOptional =
7819
- fix.first .isUnwrapOptionalBaseByOptionalChaining (*this );
7820
- MemberAccessOnOptionalBaseFailure failure (expr, solution, locator,
7821
- memberName, resultIsOptional);
7822
- return failure.diagnose ();
7823
- }
7824
-
7825
- case FixKind::ForceDowncast: {
7826
- MissingExplicitConversionFailure failure (expr, solution, locator,
7827
- fix.first .getTypeArgument (*this ));
7828
- return failure.diagnose ();
7829
- }
7830
-
7831
- case FixKind::AddressOf: {
7832
- MissingAddressOfFailure failure (expr, solution, locator);
7833
- return failure.diagnose ();
7834
- }
7835
-
7836
- case FixKind::CoerceToCheckedCast: {
7837
- MissingForcedDowncastFailure failure (expr, solution, locator);
7838
- return failure.diagnose ();
7839
- }
7840
-
7841
- case FixKind::ExplicitlyEscaping: {
7842
- NoEscapeFuncToTypeConversionFailure failure (expr, solution, locator);
7843
- return failure.diagnose ();
7844
- }
7845
-
7846
- case FixKind::ExplicitlyEscapingToAny: {
7847
- NoEscapeFuncToTypeConversionFailure failure (expr, solution, locator,
7848
- getASTContext ().TheAnyType );
7849
- return failure.diagnose ();
7850
- }
7851
-
7852
- case FixKind::RelabelArguments: {
7853
- LabelingFailure failure (solution, fix.second ,
7854
- fix.first .getArgumentLabels (*this ));
7855
- return failure.diagnose ();
7856
- }
7857
-
7858
- case FixKind::AddConformance: {
7859
- auto *anchor = locator->getAnchor ();
7860
- auto &reqLoc = locator->getPath ().back ();
7861
- MissingConformanceFailure failure (
7862
- expr, solution, fix.second ,
7863
- MissingConformances[{anchor, reqLoc.getValue ()}]);
7864
- return failure.diagnose ();
7865
- }
7866
- }
7867
-
7868
- // FIXME: It would be really nice to emit a follow-up note showing where
7869
- // we got the other type information from, e.g., the parameter we're
7870
- // initializing.
7871
- return false ;
7872
- }
7873
-
7874
-
7875
7794
// / \brief Apply a given solution to the expression, producing a fully
7876
7795
// / type-checked expression.
7877
7796
Expr *ConstraintSystem::applySolution (Solution &solution, Expr *expr,
0 commit comments