diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index dd0572ee08baa..afe708f9fa38a 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -5271,14 +5271,10 @@ bool MissingGenericArgumentsFailure::diagnoseAsError() { scopedParameters[base].push_back(GP); }); - // FIXME: this code should be generalized now that we can anchor the - // fixes on the TypeRepr with the missing generic arg. if (!isScoped) { - assert(getAnchor().is() || getAnchor().is()); - if (auto *expr = getAsExpr(getAnchor())) - return diagnoseForAnchor(expr, Parameters); - - return diagnoseForAnchor(getAnchor().get(), Parameters); + auto anchor = getAnchor(); + assert(anchor.is() || anchor.is()); + return diagnoseForAnchor(anchor, Parameters); } bool diagnosed = false; @@ -5288,7 +5284,7 @@ bool MissingGenericArgumentsFailure::diagnoseAsError() { } bool MissingGenericArgumentsFailure::diagnoseForAnchor( - Anchor anchor, ArrayRef params) const { + ASTNode anchor, ArrayRef params) const { bool diagnosed = false; for (auto *GP : params) diagnosed |= diagnoseParameter(anchor, GP); @@ -5322,11 +5318,9 @@ bool MissingGenericArgumentsFailure::diagnoseForAnchor( } bool MissingGenericArgumentsFailure::diagnoseParameter( - Anchor anchor, GenericTypeParamType *GP) const { + ASTNode anchor, GenericTypeParamType *GP) const { auto &solution = getSolution(); - - auto loc = anchor.is() ? anchor.get()->getLoc() - : anchor.get()->getLoc(); + auto loc = ::getLoc(anchor); auto *locator = getLocator(); // Type variables associated with missing generic parameters are @@ -5372,7 +5366,7 @@ bool MissingGenericArgumentsFailure::diagnoseParameter( } void MissingGenericArgumentsFailure::emitGenericSignatureNote( - Anchor anchor) const { + ASTNode anchor) const { auto &solution = getSolution(); auto *paramDC = getDeclContext(); diff --git a/lib/Sema/CSDiagnostics.h b/lib/Sema/CSDiagnostics.h index c684aa2096959..4889dbeab30dc 100644 --- a/lib/Sema/CSDiagnostics.h +++ b/lib/Sema/CSDiagnostics.h @@ -1698,8 +1698,6 @@ class InOutConversionFailure final : public ContextualFailure { /// _ = S() /// ``` class MissingGenericArgumentsFailure final : public FailureDiagnostic { - using Anchor = llvm::PointerUnion; - SmallVector Parameters; public: @@ -1722,13 +1720,13 @@ class MissingGenericArgumentsFailure final : public FailureDiagnostic { bool diagnoseAsError() override; - bool diagnoseForAnchor(Anchor anchor, + bool diagnoseForAnchor(ASTNode anchor, ArrayRef params) const; - bool diagnoseParameter(Anchor anchor, GenericTypeParamType *GP) const; + bool diagnoseParameter(ASTNode anchor, GenericTypeParamType *GP) const; private: - void emitGenericSignatureNote(Anchor anchor) const; + void emitGenericSignatureNote(ASTNode anchor) const; /// Retrieve representative locations for associated generic prameters. ///