Skip to content

Commit e2e57ad

Browse files
committed
[ConstraintSystem] Turn 'omit ' into a contextual mismatch it is
1 parent 13b4fcc commit e2e57ad

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/Sema/CSFix.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,14 +894,19 @@ RemoveAddressOf *RemoveAddressOf::create(ConstraintSystem &cs, Type lhs, Type rh
894894
return new (cs.getAllocator()) RemoveAddressOf(cs, lhs, rhs, locator);
895895
}
896896

897+
RemoveReturn::RemoveReturn(ConstraintSystem &cs, Type resultTy,
898+
ConstraintLocator *locator)
899+
: ContextualMismatch(cs, FixKind::RemoveReturn, resultTy,
900+
cs.getASTContext().TheEmptyTupleType, locator) {}
901+
897902
bool RemoveReturn::diagnose(const Solution &solution, bool asNote) const {
898903
ExtraneousReturnFailure failure(solution, getLocator());
899904
return failure.diagnose(asNote);
900905
}
901906

902-
RemoveReturn *RemoveReturn::create(ConstraintSystem &cs,
907+
RemoveReturn *RemoveReturn::create(ConstraintSystem &cs, Type resultTy,
903908
ConstraintLocator *locator) {
904-
return new (cs.getAllocator()) RemoveReturn(cs, locator);
909+
return new (cs.getAllocator()) RemoveReturn(cs, resultTy, locator);
905910
}
906911

907912
bool CollectionElementContextualMismatch::diagnose(const Solution &solution,

lib/Sema/CSFix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,16 +1405,16 @@ class AllowInvalidRefInKeyPath final : public ConstraintFix {
14051405
ConstraintLocator *locator);
14061406
};
14071407

1408-
class RemoveReturn final : public ConstraintFix {
1409-
RemoveReturn(ConstraintSystem &cs, ConstraintLocator *locator)
1410-
: ConstraintFix(cs, FixKind::RemoveReturn, locator) {}
1408+
class RemoveReturn final : public ContextualMismatch {
1409+
RemoveReturn(ConstraintSystem &cs, Type resultTy, ConstraintLocator *locator);
14111410

14121411
public:
14131412
std::string getName() const override { return "remove or omit return type"; }
14141413

14151414
bool diagnose(const Solution &solution, bool asNote = false) const override;
14161415

1417-
static RemoveReturn *create(ConstraintSystem &cs, ConstraintLocator *locator);
1416+
static RemoveReturn *create(ConstraintSystem &cs, Type resultTy,
1417+
ConstraintLocator *locator);
14181418
};
14191419

14201420
class CollectionElementContextualMismatch final : public ContextualMismatch {

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3881,7 +3881,7 @@ bool ConstraintSystem::repairFailures(
38813881
if (rhs->isVoid() &&
38823882
(purpose == CTP_ReturnStmt || purpose == CTP_ReturnSingleExpr)) {
38833883
conversionsOrFixes.push_back(
3884-
RemoveReturn::create(*this, getConstraintLocator(locator)));
3884+
RemoveReturn::create(*this, lhs, getConstraintLocator(locator)));
38853885
return true;
38863886
}
38873887

0 commit comments

Comments
 (0)