QmlDesigner: Use proper features of std::variant instead of overloads

Change-Id: I6423155701b92d09011aaf913d845fa59148b207
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ali Kianian
2023-08-30 13:08:49 +03:00
parent b46a0e8e1d
commit 83ad97aa56

View File

@@ -84,15 +84,6 @@ inline bool isAcceptedIfBinaryOperator(const int &operation)
} }
} }
inline bool areOfTheSameTypeMatch(const MatchedStatement &m1, const MatchedStatement &m2)
{
return std::visit(Overload{[](auto m1, auto m2) -> bool {
return std::is_same<decltype(m1), decltype(m2)>();
}},
m1,
m2);
}
class NodeStatus class NodeStatus
{ {
public: public:
@@ -1071,19 +1062,12 @@ void ConnectionEditorEvaluator::endVisit(QmlJS::AST::IfStatement *ifStatement)
if (status() != UnFinished) if (status() != UnFinished)
return; return;
std::visit(Overload{[this](const ConnectionEditorStatements::ConditionalStatement &statement) { if (auto statement = std::get_if<ConditionalStatement>(&d->m_handler)) {
if (!ConnectionEditorStatements::isEmptyStatement(statement.ok) if (!isEmptyStatement(statement->ok) && !isEmptyStatement(statement->ko)) {
&& !ConnectionEditorStatements::isEmptyStatement(statement.ko)) { if (statement->ok.index() != statement->ko.index())
qDebug() << Q_FUNC_INFO d->checkValidityAndReturn(false, "Matched statements types are mismatched");
<< areOfTheSameTypeMatch(statement.ok, statement.ko); }
if (!areOfTheSameTypeMatch(statement.ok, statement.ko)) { }
d->checkValidityAndReturn(
false, "Matched statements types are mismatched");
}
}
},
[](auto) {}},
d->m_handler);
} }
void ConnectionEditorEvaluator::endVisit(QmlJS::AST::StatementList *statementList) void ConnectionEditorEvaluator::endVisit(QmlJS::AST::StatementList *statementList)