diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-16 17:03:01 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-26 12:18:15 +0000 |
| commit | 8bf5aae19b77b618f3f7a55a59e87c8a319475a8 (patch) | |
| tree | d331328f478ac13593524eaaeb3a874691ccadd2 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 23fc22e16022e355f2a1aff8705c09b807fbe024 (diff) | |
QtQml: Properly enforce signatures of AOT-compiled functions
Pass the metatypes of the contained types rather than the stored types.
[ChangeLog][QtQml][Important Behavior Changes] The AOT compiled code for
type-annotated JavaScript functions does not let you pass or return
values of the wrong type anymore.
Fixes: QTBUG-119885
Change-Id: I685d398c0745d32a999a3abd76c622a2c0d6651f
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 | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index ae8ef49b22..9b66143f62 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -89,6 +89,7 @@ private slots: void enumProblems(); void enumScope(); void enums(); + void enforceSignature(); void enumsInOtherObject(); void equalityQObjects(); void equalityQUrl(); @@ -1652,6 +1653,23 @@ void tst_QmlCppCodegen::enums() } +void tst_QmlCppCodegen::enforceSignature() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/enforceSignature.qml"_s)); + QVERIFY2(!component.isError(), component.errorString().toUtf8()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + const QVariant a = object->property("a"); + QCOMPARE(a.metaType(), QMetaType::fromType<QObject *>()); + QCOMPARE(a.value<QObject *>(), nullptr); + + const QVariant b = object->property("b"); + QCOMPARE(b.metaType(), QMetaType::fromType<QObject *>()); + QCOMPARE(b.value<QObject *>(), nullptr); +} + void tst_QmlCppCodegen::enumsInOtherObject() { QQmlEngine engine; @@ -1865,9 +1883,8 @@ void tst_QmlCppCodegen::failures() { const auto &aotFailure = QmlCacheGeneratedCode::_qt_qml_TestTypes_failures_qml::aotBuiltFunctions[0]; - QVERIFY(aotFailure.argumentTypes.isEmpty()); QVERIFY(!aotFailure.functionPtr); - QCOMPARE(aotFailure.extraData, 0); + QCOMPARE(aotFailure.functionIndex, 0); } void tst_QmlCppCodegen::fallbackLookups() |
