diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-06-09 13:57:18 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2023-06-12 13:32:15 +0200 |
| commit | 583e8c82169e9859674502b285230e545f918ce2 (patch) | |
| tree | f4329821a8732a12a366a30f8ead433a400f6785 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 9e322ea167e11cbe44c7fcb5a3459b02e0d82232 (diff) | |
QmlCompiler: Add missing conversion for equality with null or undefined
The result of the equality check is a bool. However, the expression
using that value may expect another type. It therefore needs to be
converted to that type. This was done implicitly until now because of
the missing explicit conversions. This is a problem because introducing
more conversion options causes an ambiguity in the choice of the
conversion to use. Leading to a compilation error.
For this reason the test is run in a Window because this includes
enough other code to make the implicit conversion ambiguous.
Fixes: QTBUG-114418
Pick-to: 6.5 6.6
Change-Id: I1c3f9ee21f9719cdfbce748a4fd0a687def9d1bf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index cc55445983..3fd4e9c619 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -190,6 +190,7 @@ private slots: void variantReturn(); void variantlist(); void voidFunction(); + void equalityTestsWithNullOrUndefined(); }; static QByteArray arg1() @@ -3911,6 +3912,15 @@ void tst_QmlCppCodegen::voidFunction() QCOMPARE(object->objectName(), u"barbar"_s); } +void tst_QmlCppCodegen::equalityTestsWithNullOrUndefined() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/equalityTestsWithNullOrUndefined.qml"_s)); + QVERIFY2(component.isReady(), component.errorString().toUtf8()); + QScopedPointer<QObject> o(component.create()); + QVERIFY(o); +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
