diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-08-23 14:38:59 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-29 15:33:26 +0000 |
commit | 0e5d277bbf66d6b9a75e22d3c60a8fca5368cf6b (patch) | |
tree | 860e21d7153754145e774d597ee8117e4b28b18c | |
parent | 61e269ded1918624e15fd862daa9f69cc58f1ba9 (diff) |
qmllint: Don't warn about access to attached enums
You can always access enums of attached objects, no matter what other
rules apply to the attached properties.
Fixes: QTBUG-105590
Change-Id: I07878d8efe63468539168aa2c2842e3159ed2090
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit cc89f62851ce1b9f859e9bc43415d4ce7e3a36e2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/qmllint/quick/quicklintplugin.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/enumsOfScrollBar.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp index fca4fecc36..c266bfbe11 100644 --- a/src/plugins/qmllint/quick/quicklintplugin.cpp +++ b/src/plugins/qmllint/quick/quicklintplugin.cpp @@ -132,10 +132,10 @@ void AttachedPropertyTypeValidatorPass::onRead(const QQmlSA::Element &element, const QQmlSA::Element &readScope, QQmlJS::SourceLocation location) { - Q_UNUSED(readScope) - Q_UNUSED(propertyName) - - checkWarnings(element, readScope, location); + // If the attachment does not have such a property or method then + // it's either a more general error or an enum. Enums are fine. + if (element->hasProperty(propertyName) || element->hasMethod(propertyName)) + checkWarnings(element, readScope, location); } void AttachedPropertyTypeValidatorPass::onWrite(const QQmlSA::Element &element, diff --git a/tests/auto/qml/qmllint/data/enumsOfScrollBar.qml b/tests/auto/qml/qmllint/data/enumsOfScrollBar.qml new file mode 100644 index 0000000000..d0cd5591b9 --- /dev/null +++ b/tests/auto/qml/qmllint/data/enumsOfScrollBar.qml @@ -0,0 +1,7 @@ +import QtQuick +import QtQuick.Controls + +Item { + Component.onCompleted: console.log(ScrollBar.AlwaysOn) +} + diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index e0e690ed99..33abde0400 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -1145,6 +1145,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("BindingTypeMismatchFunction") << QStringLiteral("bindingTypeMismatchFunction.qml"); QTest::newRow("BindingTypeMismatch") << QStringLiteral("bindingTypeMismatch.qml"); QTest::newRow("template literal (substitution)") << QStringLiteral("templateStringSubstitution.qml"); + QTest::newRow("enumsOfScrollBar") << QStringLiteral("enumsOfScrollBar.qml"); } void TestQmllint::cleanQmlCode() |