diff options
Diffstat (limited to 'tools/qmllint/checkidentifiers.cpp')
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index 32a47891d5..6400e5db77 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -76,19 +76,14 @@ void CheckIdentifiers::printContext( + QLatin1Char('\n'), Normal); } -static bool walkViaParentAndAttachedScopes(QQmlJSScope::ConstPtr rootType, - std::function<bool(QQmlJSScope::ConstPtr)> visit) +template<typename Visitor> +static bool walkRelatedScopes(QQmlJSScope::ConstPtr rootType, const Visitor &visit) { if (rootType.isNull()) return false; std::stack<QQmlJSScope::ConstPtr> stack; stack.push(rootType); - if (!rootType->isComposite()) { - if (auto extension = rootType->extensionType()) - stack.push(extension); - } - while (!stack.empty()) { const auto type = stack.top(); stack.pop(); @@ -96,17 +91,17 @@ static bool walkViaParentAndAttachedScopes(QQmlJSScope::ConstPtr rootType, if (visit(type)) return true; - if (auto superType = type->baseType()) { - stack.push(superType); - if (type->isComposite() && !superType->isComposite()) { - if (auto extension = superType->extensionType()) - stack.push(extension); - } - } - if (auto attachedType = type->attachedType()) stack.push(attachedType); + + if (auto baseType = type->baseType()) + stack.push(baseType); + + // Push extension type last. It overrides the base type. + if (auto extensionType = type->extensionType()) + stack.push(extensionType); } + return false; } @@ -233,7 +228,7 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members, rootType = scope; bool typeFound = - walkViaParentAndAttachedScopes(rootType, [&](QQmlJSScope::ConstPtr type) { + walkRelatedScopes(rootType, [&](QQmlJSScope::ConstPtr type) { const auto typeProperties = type->ownProperties(); const auto typeIt = typeProperties.find(access.m_name); if (typeIt != typeProperties.end()) { |