aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmllint
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-02-20 15:04:21 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-02-29 12:08:08 +0100
commit7da544e862a92cc0a9d97cbed68a35c532699116 (patch)
tree9abdef4794520fed6d8a142dc15a5adecd222334 /tests/auto/qml/qmllint
parentd289b67cedb1b910f1f7eb1b3c1f95a7413defdc (diff)
QmlCompiler: Respect scoped enums
Correctly propagate the isClass and RegisterEnumClassesUnscoped information from metatypes to qmltypes, then read it correctly, and don't try to resolve unscoped values of scoped enums when resolving types. Neither try to resolve the names of unscoped enums. For historical reasons, enums are unscoped by default, even if they are declared as "enum class". Furthermore, QML enums can be accessed in both scoped and unscoped way. Scoped C++ enums can only be accessed by explicitly stating the scope, and unscoped C++ enums can only be accessed without scope. Since qmllint now correctly analyzes this, we need to adapt the tests accordingly. Finally, also fix the logic around populating the error message for qmllint. We want to warn about the enum itself, not one of its values. And we always want to setError() if something is wrong so that the compilers don't try to continue from there. Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-107143 Change-Id: If1ee9a10479cffb46067ccb5e683906905c24160 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/qmllint')
-rw-r--r--tests/auto/qml/qmllint/data/Things/plugins.qmltypes3
-rw-r--r--tests/auto/qml/qmllint/data/qmldirAndQmltypes.qml2
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp4
3 files changed, 5 insertions, 4 deletions
diff --git a/tests/auto/qml/qmllint/data/Things/plugins.qmltypes b/tests/auto/qml/qmllint/data/Things/plugins.qmltypes
index 45a6af32ab..453e81d57a 100644
--- a/tests/auto/qml/qmllint/data/Things/plugins.qmltypes
+++ b/tests/auto/qml/qmllint/data/Things/plugins.qmltypes
@@ -12,6 +12,7 @@ Module {
exports: ["Things/SomethingEntirelyStrange 1.0"]
Enum {
name: "AnEnum"
+ isScoped: true
values: {
"AAA": 0,
"BBB": 1,
@@ -20,7 +21,7 @@ Module {
}
Enum {
name: "TheEnum"
- scoped: false
+ isScoped: false
values: {
"V1": 0,
"V2": 1
diff --git a/tests/auto/qml/qmllint/data/qmldirAndQmltypes.qml b/tests/auto/qml/qmllint/data/qmldirAndQmltypes.qml
index 4847fc9196..ad88f1c58c 100644
--- a/tests/auto/qml/qmllint/data/qmldirAndQmltypes.qml
+++ b/tests/auto/qml/qmllint/data/qmldirAndQmltypes.qml
@@ -2,5 +2,5 @@ import Things 1.0
Something {
property var a: SomethingEntirelyStrange {}
- property var b: SomethingEntirelyStrange.AAA
+ property var b: SomethingEntirelyStrange.AnEnum.AAA
}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 753a4d3af9..9929d0c850 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -1060,8 +1060,8 @@ expression: \${expr} \${expr} \\\${expr} \\\${expr}`)",
QTest::newRow("NotScopedEnumCpp")
<< QStringLiteral("NotScopedEnumCpp.qml")
<< Result{ { Message{
- QStringLiteral("You cannot access unscoped enum \"V1\" from here."), 5,
- 57 } } };
+ QStringLiteral("You cannot access unscoped enum \"TheEnum\" from here."), 5,
+ 49 } } };
QTest::newRow("unresolvedArrayBinding")
<< QStringLiteral("unresolvedArrayBinding.qml")