aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/qml/qmllint/data/Things/plugins.qmltypes1
-rw-r--r--tests/auto/qml/qmllint/data/incompleteQmltypes.qml6
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp4
-rw-r--r--tools/qmllint/scopetree.cpp21
4 files changed, 30 insertions, 2 deletions
diff --git a/tests/auto/qml/qmllint/data/Things/plugins.qmltypes b/tests/auto/qml/qmllint/data/Things/plugins.qmltypes
index 00cda191cc..9d81c21070 100644
--- a/tests/auto/qml/qmllint/data/Things/plugins.qmltypes
+++ b/tests/auto/qml/qmllint/data/Things/plugins.qmltypes
@@ -12,5 +12,6 @@ Module {
"CCC": 2
}
}
+ Property { name: "palette"; type: "QPalette" }
}
}
diff --git a/tests/auto/qml/qmllint/data/incompleteQmltypes.qml b/tests/auto/qml/qmllint/data/incompleteQmltypes.qml
new file mode 100644
index 0000000000..ab06bbd8b0
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/incompleteQmltypes.qml
@@ -0,0 +1,6 @@
+import Things 1.0
+
+SomethingEntirelyStrange {
+ id: self
+ property var a: self.palette.weDontKnowIt
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index ed401d59e0..ed968d6623 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -160,6 +160,10 @@ void TestQmllint::dirtyQmlCode_data()
<< QStringLiteral("badTypeAssertion.qml")
<< QString("Warning: Property \"rrr\" not found on type \"Item\" at 5:39")
<< QString();
+ QTest::newRow("incompleteQmltypes")
+ << QStringLiteral("incompleteQmltypes.qml")
+ << QString("Warning: Type \"QPalette\" of member \"palette\" not found at 5:26")
+ << QString();
}
void TestQmllint::dirtyQmlCode()
diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp
index 07413094c0..8c5358c7a5 100644
--- a/tools/qmllint/scopetree.cpp
+++ b/tools/qmllint/scopetree.cpp
@@ -179,13 +179,30 @@ bool ScopeTree::checkMemberAccess(
return true;
}
+ if (!access->m_child)
+ return true;
+
if (const ScopeTree *type = scopeIt->type()) {
if (access->m_parentType.isEmpty())
return checkMemberAccess(code, access.get(), type, types, colorOut);
}
- return unknownBuiltins.contains(typeName) || checkMemberAccess(
- code, access.get(), types.value(typeName).get(), types, colorOut);
+ if (unknownBuiltins.contains(typeName))
+ return true;
+
+ const auto it = types.find(typeName);
+ if (it != types.end())
+ return checkMemberAccess(code, access.get(), it->get(), types, colorOut);
+
+ colorOut.write("Warning: ", Warning);
+ colorOut.write(
+ QString::fromLatin1("Type \"%1\" of member \"%2\" not found at %3:%4.\n")
+ .arg(typeName)
+ .arg(access->m_name)
+ .arg(access->m_location.startLine)
+ .arg(access->m_location.startColumn), Normal);
+ printContext(colorOut, code, access->m_location);
+ return false;
}
const auto scopeMethodIt = scope->m_methods.find(access->m_name);