Skip to content

Commit 9b5cf1d

Browse files
committed
[Diagnostics] Remove the MacroMissingArguments constraint fix and its
associated failure diagnostic. This constraint fix is unused now that MacroExpansionExpr always has an argument list, and goes through the AddMissingArguments constraint fix for this error.
1 parent 26786c1 commit 9b5cf1d

File tree

6 files changed

+0
-114
lines changed

6 files changed

+0
-114
lines changed

include/swift/Sema/CSFix.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,6 @@ enum class FixKind : uint8_t {
419419
/// Macro without leading #.
420420
MacroMissingPound,
421421

422-
/// Macro that has parameters but was not provided with any arguments.
423-
MacroMissingArguments,
424-
425422
/// Allow function type actor mismatch e.g. `@MainActor () -> Void`
426423
/// vs.`@OtherActor () -> Void`
427424
AllowGlobalActorMismatch,
@@ -3268,32 +3265,6 @@ class MacroMissingPound final : public ConstraintFix {
32683265
}
32693266
};
32703267

3271-
class MacroMissingArguments final : public ConstraintFix {
3272-
MacroDecl *macro;
3273-
3274-
MacroMissingArguments(ConstraintSystem &cs, MacroDecl *macro,
3275-
ConstraintLocator *locator)
3276-
: ConstraintFix(cs, FixKind::MacroMissingArguments, locator),
3277-
macro(macro) { }
3278-
3279-
public:
3280-
std::string getName() const override { return "macro missing arguments"; }
3281-
3282-
bool diagnose(const Solution &solution, bool asNote = false) const override;
3283-
3284-
bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override {
3285-
return diagnose(*commonFixes.front().first);
3286-
}
3287-
3288-
static MacroMissingArguments *
3289-
create(ConstraintSystem &cs, MacroDecl *macro,
3290-
ConstraintLocator *locator);
3291-
3292-
static bool classof(ConstraintFix *fix) {
3293-
return fix->getKind() == FixKind::MacroMissingArguments;
3294-
}
3295-
};
3296-
32973268
/// Allow mismatch between function types global actors.
32983269
/// e.g. `@MainActor () -> Void` vs.`@OtherActor () -> Void`
32993270
class AllowGlobalActorMismatch final : public ContextualMismatch {

lib/Sema/CSDiagnostics.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8530,35 +8530,6 @@ bool AddMissingMacroPound::diagnoseAsError() {
85308530
return true;
85318531
}
85328532

8533-
bool AddMissingMacroArguments::diagnoseAsError() {
8534-
std::string argumentString;
8535-
{
8536-
llvm::raw_string_ostream out(argumentString);
8537-
out << "(";
8538-
llvm::interleave(
8539-
macro->parameterList->begin(), macro->parameterList->end(),
8540-
[&](ParamDecl *param) {
8541-
if (!param->getArgumentName().empty()) {
8542-
out << param->getArgumentName() << ": ";
8543-
}
8544-
8545-
out << "<#" << param->getInterfaceType().getString() << "#" << ">";
8546-
},
8547-
[&] {
8548-
out << ", ";
8549-
});
8550-
out << ")";
8551-
}
8552-
8553-
auto insertLoc = getRawAnchor().getEndLoc();
8554-
emitDiagnostic(diag::macro_expansion_missing_arguments, macro->getName())
8555-
.fixItInsertAfter(insertLoc, argumentString);
8556-
macro->diagnose(
8557-
diag::kind_declname_declared_here, macro->getDescriptiveKind(),
8558-
macro->getName());
8559-
return true;
8560-
}
8561-
85628533
bool GlobalActorFunctionMismatchFailure::diagnoseTupleElement() {
85638534
auto *locator = getLocator();
85648535
auto path = locator->getPath();

lib/Sema/CSDiagnostics.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,29 +2877,6 @@ class AddMissingMacroPound final : public FailureDiagnostic {
28772877
bool diagnoseAsError() override;
28782878
};
28792879

2880-
/// Diagnose situations where we end up type checking a reference to a macro
2881-
/// that has parameters, but was not provided any arguments.
2882-
///
2883-
/// \code
2884-
/// func print(_ value: Any)
2885-
/// @expression macro print<Value...>(_ value: Value...)
2886-
///
2887-
/// func test(e: E) {
2888-
/// #print
2889-
/// }
2890-
/// \endcode
2891-
class AddMissingMacroArguments final : public FailureDiagnostic {
2892-
MacroDecl *macro;
2893-
2894-
public:
2895-
AddMissingMacroArguments(const Solution &solution, MacroDecl *macro,
2896-
ConstraintLocator *locator)
2897-
: FailureDiagnostic(solution, locator),
2898-
macro(macro) { }
2899-
2900-
bool diagnoseAsError() override;
2901-
};
2902-
29032880
/// Diagnose function types global actor mismatches
29042881
/// e.g. `@MainActor () -> Void` vs.`@OtherActor () -> Void`
29052882
class GlobalActorFunctionMismatchFailure final : public ContextualFailure {

lib/Sema/CSFix.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,18 +2614,6 @@ MacroMissingPound::create(ConstraintSystem &cs, MacroDecl *macro,
26142614
return new (cs.getAllocator()) MacroMissingPound(cs, macro, locator);
26152615
}
26162616

2617-
bool MacroMissingArguments::diagnose(const Solution &solution,
2618-
bool asNote) const {
2619-
AddMissingMacroArguments failure(solution, macro, getLocator());
2620-
return failure.diagnose(asNote);
2621-
}
2622-
2623-
MacroMissingArguments *
2624-
MacroMissingArguments::create(ConstraintSystem &cs, MacroDecl *macro,
2625-
ConstraintLocator *locator) {
2626-
return new (cs.getAllocator()) MacroMissingArguments(cs, macro, locator);
2627-
}
2628-
26292617
bool AllowGlobalActorMismatch::diagnose(const Solution &solution,
26302618
bool asNote) const {
26312619
GlobalActorFunctionMismatchFailure failure(solution, getFromType(),

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13944,7 +13944,6 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1394413944
case FixKind::NotCompileTimeConst:
1394513945
case FixKind::RenameConflictingPatternVariables:
1394613946
case FixKind::MacroMissingPound:
13947-
case FixKind::MacroMissingArguments:
1394813947
case FixKind::AllowGlobalActorMismatch: {
1394913948
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
1395013949
}

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,26 +3594,6 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
35943594
// Record a fix here
35953595
(void)recordFix(MacroMissingPound::create(*this, macro, locator));
35963596
}
3597-
3598-
// If the macro has parameters but wasn't provided with any arguments,
3599-
// introduce a fix to add the arguments.
3600-
bool isCall;
3601-
switch (choice.getFunctionRefKind()) {
3602-
case FunctionRefKind::SingleApply:
3603-
case FunctionRefKind::DoubleApply:
3604-
isCall = true;
3605-
break;
3606-
3607-
case FunctionRefKind::Unapplied:
3608-
case FunctionRefKind::Compound:
3609-
// Note: macros don't have compound name references.
3610-
isCall = false;
3611-
break;
3612-
}
3613-
if (macro->parameterList && !isCall) {
3614-
// Record a fix here
3615-
(void)recordFix(MacroMissingArguments::create(*this, macro, locator));
3616-
}
36173597
}
36183598
}
36193599

0 commit comments

Comments
 (0)