From 83ad97aa56db58a41ed623dddeed7161dba37969 Mon Sep 17 00:00:00 2001 From: Ali Kianian Date: Wed, 30 Aug 2023 13:08:49 +0300 Subject: [PATCH] QmlDesigner: Use proper features of std::variant instead of overloads Change-Id: I6423155701b92d09011aaf913d845fa59148b207 Reviewed-by: Marco Bubke --- .../connectioneditorevaluator.cpp | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectioneditorevaluator.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectioneditorevaluator.cpp index fccb5b11941..b375ee613b2 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectioneditorevaluator.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectioneditorevaluator.cpp @@ -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(); - }}, - m1, - m2); -} - class NodeStatus { public: @@ -1071,19 +1062,12 @@ void ConnectionEditorEvaluator::endVisit(QmlJS::AST::IfStatement *ifStatement) if (status() != UnFinished) return; - std::visit(Overload{[this](const ConnectionEditorStatements::ConditionalStatement &statement) { - if (!ConnectionEditorStatements::isEmptyStatement(statement.ok) - && !ConnectionEditorStatements::isEmptyStatement(statement.ko)) { - qDebug() << Q_FUNC_INFO - << areOfTheSameTypeMatch(statement.ok, statement.ko); - if (!areOfTheSameTypeMatch(statement.ok, statement.ko)) { - d->checkValidityAndReturn( - false, "Matched statements types are mismatched"); - } - } - }, - [](auto) {}}, - d->m_handler); + if (auto statement = std::get_if(&d->m_handler)) { + if (!isEmptyStatement(statement->ok) && !isEmptyStatement(statement->ko)) { + if (statement->ok.index() != statement->ko.index()) + d->checkValidityAndReturn(false, "Matched statements types are mismatched"); + } + } } void ConnectionEditorEvaluator::endVisit(QmlJS::AST::StatementList *statementList)