diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-11-01 18:56:32 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-11-04 01:29:26 +0100 |
| commit | d0484963f4b8839c3e43ad0d72e2bc6c4fbfb512 (patch) | |
| tree | fab842128026ad55fcb95eeb41154711b9346f82 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | cebb3a732041d4254e8fd1a0b41e19f027351e92 (diff) | |
QmlCompiler: Allow internal conversions from wrapped original types
If an original type is merely wrapped into a more generic type by the
basic blocks pass, we know the original data is still there and can be
used for conversion.
This happens if we assign the same value once via a shadowable lookup
and once via an exactly typed one. The basic blocks pass then has to
produce a QVariant for the shadowable lookup. However, we know that it
can only contain the original type.
Fixes: QTBUG-117800
Change-Id: I42335c3404dbcf8c1e7ad6427d22643ad490a345
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 6b4f604d00..b8364a51b2 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -117,6 +117,7 @@ private slots: void interceptor(); void interestingFiles(); void interestingFiles_data(); + void internalConversion(); void invalidPropertyType(); void invisibleBase(); void invisibleListElementType(); @@ -2208,6 +2209,21 @@ void tst_QmlCppCodegen::interestingFiles_data() QTest::addRow("moveRegVoid") << u"moveRegVoid.qml"_s << true; } +void tst_QmlCppCodegen::internalConversion() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/internalConversion.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(!obj.isNull()); + + QObject *offset = obj->property("offset").value<QObject *>(); + QVERIFY(offset); + + QCOMPARE(offset->objectName(), "hello"_L1); + QCOMPARE(offset->property("mark").toString(), "hello"_L1); +} + void tst_QmlCppCodegen::invalidPropertyType() { // Invisible on purpose |
