aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-12-17 14:23:55 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-01-21 14:23:08 +0100
commitcb4e0c119607a48e1f5e0cea9273afd914c15b25 (patch)
tree4717b75e129bc26bbb1b792092038a6c223617ae /tests
parentdab5656d38a3d53c2d81b20e9bb8bc162edf7716 (diff)
QmlCompiler: Respect revisions
The only place where revisions matter is at the boundary between composite and non-composite types. The revision of the first composite type inherited from determines which members of all composite ancestors are available. Therefore, store the revision together with the base type and pass it through the imports to have it available. Then use it to check availability of methods and properties. The test exposes two further problems, which are fixed, too: 1. If no method is found to call, we need to generate an error in the type propagator. We don't know what the call will result in, after all, and the code generator should reject it. 2. We need to check the right scopes for hasOwnMethod(). Otherwise we might not find methods that are available. Fixes: QTBUG-99128 Change-Id: I4c320b8dfb490b140d7b8c16e6b638b32f156faa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e19d48d07310708e56cb379124dff193c1a7fa71)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/revisions.qml21
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp13
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp8
4 files changed, 38 insertions, 5 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index 31709b46ea..8c321a6534 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -94,6 +94,7 @@ set(qml_files
popContextAfterRet.qml
pressAndHoldButton.qml
registerelimination.qml
+ revisions.qml
scopeVsObject.qml
script.js
script.mjs
diff --git a/tests/auto/qml/qmlcppcodegen/data/revisions.qml b/tests/auto/qml/qmlcppcodegen/data/revisions.qml
new file mode 100644
index 0000000000..472c0996af
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/revisions.qml
@@ -0,0 +1,21 @@
+import QtQml 2.2
+
+QtObject {
+ property bool delayed: false
+ property int gotten: 0
+
+ function get(a: int) { gotten = a }
+
+ property Binding b: Binding {
+ function trigger() { delayed = true }
+ }
+
+ property ObjectModel m: ObjectModel {
+ function trigger() { get(5) }
+ }
+
+ Component.onCompleted: {
+ b.trigger()
+ m.trigger()
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 97344ceeb3..f1fad344ab 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -114,6 +114,7 @@ private slots:
void unknownAttached();
void variantlist();
void popContextAfterRet();
+ void revisions();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -1714,6 +1715,18 @@ void tst_QmlCppCodegen::popContextAfterRet()
QCOMPARE(o->objectName(), u"backgroundImage"_qs);
}
+void tst_QmlCppCodegen::revisions()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/revisions.qml"_qs));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+
+ QCOMPARE(o->property("delayed").toBool(), true);
+ QCOMPARE(o->property("gotten").toInt(), 5);
+}
+
void tst_QmlCppCodegen::runInterpreted()
{
if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER"))
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index aa54eea62c..b061262fee 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -256,11 +256,9 @@ void TestQmllint::oldQmltypes()
"oldQmltypes.qml");
// Checking for both lines separately so that we don't have to mess with the line endings.b
- searchWarnings(
- warnings,
- QStringLiteral(
- "Meta object revision and export version differ, ignoring the revision."),
- "oldQmltypes.qml");
+ searchWarnings(warnings,
+ QStringLiteral("Meta object revision and export version differ."),
+ "oldQmltypes.qml");
searchWarnings(warnings,
QStringLiteral("Revision 0 corresponds to version 0.0; it should be 1.0."),
"oldQmltypes.qml");