aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsimportvisitor.cpp
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2025-04-24 16:59:12 +0200
committerOlivier De Cannière <olivier.decanniere@qt.io>2025-04-25 14:32:24 +0200
commit41d1137fea3857f87b49ca576417cce5ef1d7300 (patch)
treeae7476273e1eaa98fa6e513abd9198fda49d5ef7 /src/qmlcompiler/qqmljsimportvisitor.cpp
parent14f1b4bce3966c58d5db2ef773e339675394e8af (diff)
qmllint: Fix required property warning with owner mixup
Because we only search for the name of the property in the scopesToSearch and not which property that name actually references, we confuse a property of the same name in a neighboring scope for the actual required one. Include the property's owning scope when searching through the scopes. Amends daf57e29de918b7b4be7bb0d469db0c51d41bb07 Fixes: QTBUG-136058 Pick-to: 6.9 6.8 Change-Id: I998901fd0840270dd2048e7257d6eaca556b513d Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index 8b9c94e2a9..4525b66930 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -958,13 +958,16 @@ void QQmlJSImportVisitor::checkRequiredProperties()
};
const auto requiredHasBinding = [](const QList<QQmlJSScope::ConstPtr> &scopesToSearch,
+ const QQmlJSScope::ConstPtr &owner,
const QString &propName) {
for (const auto &scope : scopesToSearch) {
if (scope->property(propName).isAlias())
continue;
const auto &[begin, end] = scope->ownPropertyBindings(propName);
for (auto it = begin; it != end; ++it) {
- if (QQmlSA::isRegularBindingType(it->bindingType()))
+ if (!QQmlSA::isRegularBindingType(it->bindingType()))
+ continue;
+ if (QQmlJSScope::ownerOfProperty(scope, propName).scope == owner)
return true;
}
}
@@ -1081,7 +1084,7 @@ void QQmlJSImportVisitor::checkRequiredProperties()
continue;
}
- if (requiredHasBinding(scopesToSearch, propName))
+ if (requiredHasBinding(scopesToSearch, descendant, propName))
continue;
if (requiredUsedInRootAlias(defScope, requiredScope, propName))