diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-27 16:27:13 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-03-02 13:17:47 +0100 |
| commit | fc1d25806943e1cec732deed12fd3a8f6ecf45a6 (patch) | |
| tree | 6568e196e620688ea75b9e9df61a1f7cdabe1040 /tests/auto/qml/qmlcppcodegen/data | |
| parent | 53697ba68a78bd2942902d910c5d61207ecae8aa (diff) | |
QmlCompiler: Improve method overload selection
If we have an exact match we should definitely use that.
Change-Id: I2846ecf6f9963a978b84b70fbe18acdfe6eb45e6
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/data')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/childobject.qml | 4 | ||||
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/childobject.qml b/tests/auto/qml/qmlcppcodegen/data/childobject.qml index 3775ee16bc..7d73e4fd7f 100644 --- a/tests/auto/qml/qmlcppcodegen/data/childobject.qml +++ b/tests/auto/qml/qmlcppcodegen/data/childobject.qml @@ -4,6 +4,10 @@ import TestTypes QtObject { property ObjectWithMethod child: ObjectWithMethod { objectName: "kraut" + + function doString() { overloaded("string"); } + function doNumber() { overloaded(5.2); } + function doArray() { overloaded({a: 2, b: 3, c: 3}); } } 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 348862985f..0db65d7895 100644 --- a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h +++ b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h @@ -7,6 +7,7 @@ #include <QtCore/qobject.h> #include <QtCore/qproperty.h> #include <QtQml/qqml.h> +#include <QtQml/private/qv4engine_p.h> // Make objectName available. It doesn't exist on the builtin QtObject type struct QObjectForeignForObjectName { @@ -27,6 +28,10 @@ public: Q_INVOKABLE int doThing() const { return theThing; } QProperty<int> theThing; QBindable<int> theThingBindable() { return QBindable<int>(&theThing); } + + 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")); } }; class OverriddenObjectName : public ObjectWithMethod |
