aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-07-24 21:15:25 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-07-25 16:33:29 +0200
commit747c860354e26a1e1c35e176e9c9c7f8c96e9f51 (patch)
tree2c1f50d2704d8987950a5285122df7d480842ed8 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentc3e40c89974096aa100f97fae359e6246f796af9 (diff)
QmlCompiler: Correctly handle lookups in results of method calls
Method calls often return just QVariant because we cannot be sure that the method hasn't been shadowed. In order to figure out the right lookup we should look at the type the type propagator assumed as the base of the lookup. If the type propagator was assuming a list-length lookup we need to try and generate a list-length lookup. If the base turns out to be a QVariant after shadow-checking, the code generation will cleanly fail (and refrain from generating bad code). Amends commit 46cc70e2aafc84db6caeaf747629ee6e825b0a4d. Pick-to: 6.6 Fixes: QTBUG-115278 Change-Id: I24dcd06161eb1af44450fb663d68a16d89efd6ac 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.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 841f91995c..54b5221e5d 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -147,6 +147,7 @@ private slots:
void objectInVar();
void objectLookupOnListElement();
void objectToString();
+ void objectWithStringListMethod();
void onAssignment();
void outOfBoundsArray();
void overriddenProperty();
@@ -3057,6 +3058,16 @@ void tst_QmlCppCodegen::objectToString()
QCOMPARE(o->property("no").toString(), u" no"_s); // throws, but that is ignored
}
+void tst_QmlCppCodegen::objectWithStringListMethod()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/objectWithStringListMethod.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QTest::ignoreMessage(QtDebugMsg, "2");
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+}
+
void tst_QmlCppCodegen::onAssignment()
{
QQmlEngine engine;