aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-10-17 14:06:32 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-10-23 14:44:19 +0200
commit22eaa614ea86c5f823e3de17efa1e43635b52ca7 (patch)
treedb00c82fb8a8d5b7ef9159ddcbeff7d8d31fc0dc /tests/auto/qml/qmlcppcodegen
parentb7aba647b018bc67e5b42c19752c32a7ef0336d9 (diff)
QmlCompiler: Reject calls to one of multiple fuzzy overloads
If we cannot statically determine the right overload better don't call any of them for now. Also, allow attempts to pass arguments as derived types during type propagation. The test shows that we don't properly pass the thisObject when calling with metatypes. Fix that, too. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-117922 Change-Id: I02e70ffb9a05f3cfedccafde6e16170b0efbcd29 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/childobject.qml1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h3
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp2
3 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/childobject.qml b/tests/auto/qml/qmlcppcodegen/data/childobject.qml
index 7d73e4fd7f..db6b910ec2 100644
--- a/tests/auto/qml/qmlcppcodegen/data/childobject.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/childobject.qml
@@ -8,6 +8,7 @@ QtObject {
function doString() { overloaded("string"); }
function doNumber() { overloaded(5.2); }
function doArray() { overloaded({a: 2, b: 3, c: 3}); }
+ function doFoo() { foo(this); }
}
objectName: child.objectName
property int doneThing: child.doThing()
diff --git a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h
index 3ecb6d398b..ee01d2a0d2 100644
--- a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h
+++ b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h
@@ -32,6 +32,9 @@ public:
Q_INVOKABLE void overloaded(QQmlV4Function *) { setObjectName(QStringLiteral("javaScript")); }
Q_INVOKABLE void overloaded(double) { setObjectName(QStringLiteral("double")); }
Q_INVOKABLE void overloaded(const QString &) { setObjectName(QStringLiteral("string")); }
+
+ Q_INVOKABLE void foo(const QString &bla) { setObjectName(bla); }
+ Q_INVOKABLE void foo(ObjectWithMethod *) { setObjectName(QStringLiteral("ObjectWithMethod")); }
};
class OverriddenObjectName : public ObjectWithMethod
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 3496ca25dd..486a777fef 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -3341,6 +3341,8 @@ void tst_QmlCppCodegen::overriddenProperty()
QCOMPARE(child->objectName(), u"double"_s);
QMetaObject::invokeMethod(child, "doArray");
QCOMPARE(child->objectName(), u"javaScript"_s);
+ QMetaObject::invokeMethod(child, "doFoo");
+ QCOMPARE(child->objectName(), u"ObjectWithMethod"_s);
ObjectWithMethod *benign = new ObjectWithMethod(object.data());
benign->theThing = 10;