aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmllint
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-01 15:03:19 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-01 16:51:51 +0100
commitf6fc35b45b449fe7aaca3237f29393a12fc3f90c (patch)
treebd808ac4fd916f49417f08e0e32105e614c7f0fd /tests/auto/qml/qmllint
parent24ec3b3e7fa09900d791dcaedb0820a0b1890336 (diff)
QmlCompiler: Allow for multiple extensions per object
Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmllint')
-rw-r--r--tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes41
-rw-r--r--tests/auto/qml/qmllint/data/StaticTest/qmldir2
-rw-r--r--tests/auto/qml/qmllint/data/multiExtension.qml6
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
4 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes b/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes
new file mode 100644
index 0000000000..9a2ed24482
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes
@@ -0,0 +1,41 @@
+import QtQuick.tooling 1.2
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated by qmltyperegistrar.
+
+Module {
+ Component {
+ file: "testtypes.h"
+ name: "ExtensionA"
+ accessSemantics: "reference"
+ prototype: "QObject"
+ Property { name: "a"; type: "int"; isReadonly: true; read: "a" }
+ }
+ Component {
+ file: "testtypes.h"
+ name: "ExtensionB"
+ accessSemantics: "reference"
+ prototype: "QObject"
+ Property { name: "b"; type: "int"; isReadonly: true; read: "b" }
+ }
+ Component {
+ file: "testtypes.h"
+ name: "MultiExtension"
+ accessSemantics: "reference"
+ prototype: "MultiExtensionParent"
+ exports: ["StaticTest/MultiExtension 1.0"]
+ exportMetaObjectRevisions: [256]
+ extension: "ExtensionB"
+ Property { name: "e"; type: "int"; isReadonly: true; read: "e" }
+ }
+ Component {
+ file: "testtypes.h"
+ name: "MultiExtensionParent"
+ accessSemantics: "reference"
+ prototype: "QObject"
+ extension: "ExtensionA"
+ Property { name: "p"; type: "int"; isReadonly: true; read: "p" }
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/StaticTest/qmldir b/tests/auto/qml/qmllint/data/StaticTest/qmldir
new file mode 100644
index 0000000000..4702175b79
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/StaticTest/qmldir
@@ -0,0 +1,2 @@
+module StaticTest
+typeinfo multi.qmltypes
diff --git a/tests/auto/qml/qmllint/data/multiExtension.qml b/tests/auto/qml/qmllint/data/multiExtension.qml
new file mode 100644
index 0000000000..12b36dbb4f
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/multiExtension.qml
@@ -0,0 +1,6 @@
+import StaticTest
+
+MultiExtension {
+ property int t: a + b + e + p
+}
+
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 895953c2f7..b874d3cc6f 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -337,6 +337,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("goodAliasObject") << QStringLiteral("goodAliasObject.qml");
QTest::newRow("jsmoduleimport") << QStringLiteral("jsmoduleimport.qml");
QTest::newRow("overridescript") << QStringLiteral("overridescript.qml");
+ QTest::newRow("multiExtension") << QStringLiteral("multiExtension.qml");
}
void TestQmllint::cleanQmlCode()