diff options
-rw-r--r-- | tests/auto/qml/qmllint/data/Drawer.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 | ||||
-rw-r--r-- | tools/qmllint/scopetree.cpp | 21 |
3 files changed, 24 insertions, 3 deletions
diff --git a/tests/auto/qml/qmllint/data/Drawer.qml b/tests/auto/qml/qmllint/data/Drawer.qml new file mode 100644 index 0000000000..db1d785c6c --- /dev/null +++ b/tests/auto/qml/qmllint/data/Drawer.qml @@ -0,0 +1,5 @@ +import QtQml 2.12 as T + +T.QtObject { + objectName: T.Component.objectName +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 3e5237aebe..ed401d59e0 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -194,6 +194,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("AttachedProps") << QStringLiteral("AttachedProps.qml"); QTest::newRow("unknownBuiltinFont") << QStringLiteral("ButtonLoader.qml"); QTest::newRow("confusingImport") << QStringLiteral("Dialog.qml"); + QTest::newRow("qualifiedAttached") << QStringLiteral("Drawer.qml"); } void TestQmllint::cleanQmlCode() diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp index 5c0fa526a4..07413094c0 100644 --- a/tools/qmllint/scopetree.cpp +++ b/tools/qmllint/scopetree.cpp @@ -293,9 +293,24 @@ bool ScopeTree::recheckIdentifiers( auto it = qmlIDs.find(memberAccessTree->m_name); if (it != qmlIDs.end()) { - if (!checkMemberAccess(code, memberAccessTree.get(), *it, types, colorOut)) - noUnqualifiedIdentifier = false; - continue; + if (*it != nullptr) { + if (!checkMemberAccess(code, memberAccessTree.get(), *it, types, colorOut)) + noUnqualifiedIdentifier = false; + continue; + } else if (memberAccessTree->m_child + && memberAccessTree->m_child->m_name.front().isUpper()) { + // It could be a qualified type name + const QString qualified = memberAccessTree->m_name + QLatin1Char('.') + + memberAccessTree->m_child->m_name; + const auto typeIt = types.find(qualified); + if (typeIt != types.end()) { + if (!checkMemberAccess(code, memberAccessTree->m_child.get(), typeIt->get(), + types, colorOut)) { + noUnqualifiedIdentifier = false; + } + continue; + } + } } auto qmlScope = currentScope->currentQMLScope(); |