mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintSystem] Turn 'omit ' into a contextual mismatch it is
This commit is contained in:
@@ -894,14 +894,19 @@ RemoveAddressOf *RemoveAddressOf::create(ConstraintSystem &cs, Type lhs, Type rh
|
|||||||
return new (cs.getAllocator()) RemoveAddressOf(cs, lhs, rhs, locator);
|
return new (cs.getAllocator()) RemoveAddressOf(cs, lhs, rhs, locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveReturn::RemoveReturn(ConstraintSystem &cs, Type resultTy,
|
||||||
|
ConstraintLocator *locator)
|
||||||
|
: ContextualMismatch(cs, FixKind::RemoveReturn, resultTy,
|
||||||
|
cs.getASTContext().TheEmptyTupleType, locator) {}
|
||||||
|
|
||||||
bool RemoveReturn::diagnose(const Solution &solution, bool asNote) const {
|
bool RemoveReturn::diagnose(const Solution &solution, bool asNote) const {
|
||||||
ExtraneousReturnFailure failure(solution, getLocator());
|
ExtraneousReturnFailure failure(solution, getLocator());
|
||||||
return failure.diagnose(asNote);
|
return failure.diagnose(asNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveReturn *RemoveReturn::create(ConstraintSystem &cs,
|
RemoveReturn *RemoveReturn::create(ConstraintSystem &cs, Type resultTy,
|
||||||
ConstraintLocator *locator) {
|
ConstraintLocator *locator) {
|
||||||
return new (cs.getAllocator()) RemoveReturn(cs, locator);
|
return new (cs.getAllocator()) RemoveReturn(cs, resultTy, locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CollectionElementContextualMismatch::diagnose(const Solution &solution,
|
bool CollectionElementContextualMismatch::diagnose(const Solution &solution,
|
||||||
|
|||||||
@@ -1405,16 +1405,16 @@ private:
|
|||||||
ConstraintLocator *locator);
|
ConstraintLocator *locator);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RemoveReturn final : public ConstraintFix {
|
class RemoveReturn final : public ContextualMismatch {
|
||||||
RemoveReturn(ConstraintSystem &cs, ConstraintLocator *locator)
|
RemoveReturn(ConstraintSystem &cs, Type resultTy, ConstraintLocator *locator);
|
||||||
: ConstraintFix(cs, FixKind::RemoveReturn, locator) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string getName() const override { return "remove or omit return type"; }
|
std::string getName() const override { return "remove or omit return type"; }
|
||||||
|
|
||||||
bool diagnose(const Solution &solution, bool asNote = false) const override;
|
bool diagnose(const Solution &solution, bool asNote = false) const override;
|
||||||
|
|
||||||
static RemoveReturn *create(ConstraintSystem &cs, ConstraintLocator *locator);
|
static RemoveReturn *create(ConstraintSystem &cs, Type resultTy,
|
||||||
|
ConstraintLocator *locator);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CollectionElementContextualMismatch final : public ContextualMismatch {
|
class CollectionElementContextualMismatch final : public ContextualMismatch {
|
||||||
|
|||||||
@@ -3881,7 +3881,7 @@ bool ConstraintSystem::repairFailures(
|
|||||||
if (rhs->isVoid() &&
|
if (rhs->isVoid() &&
|
||||||
(purpose == CTP_ReturnStmt || purpose == CTP_ReturnSingleExpr)) {
|
(purpose == CTP_ReturnStmt || purpose == CTP_ReturnSingleExpr)) {
|
||||||
conversionsOrFixes.push_back(
|
conversionsOrFixes.push_back(
|
||||||
RemoveReturn::create(*this, getConstraintLocator(locator)));
|
RemoveReturn::create(*this, lhs, getConstraintLocator(locator)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user