diff options
-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() |