diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2026-09-08 16:07:08 +0200 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2026-09-16 13:28:12 +0000 |
| commit | 7d517f9eb14abc8a49dcef5bf40c52ac42e5a9e6 (patch) | |
| tree | 1131660e4aca486af029996ffe8f830e243c4b50 | |
| parent | e71da1f0fe4ffd572dd50df94b2d8410a7587f1e (diff) | |
qmllint: don't warn when writing to properties with missing types
Disable the "Member X not found on type" warnings on writing usages of
properties with missing types defined from the current QML file.
Amends 11c5e5b2573191e8c777e3cde3b156ca0207af88 that introduced the
warning.
Task-number: QTBUG-146734
Pick-to: 6.12
Change-Id: Iac8a98a1862e1dfb728c5468a4fe6010c3214234
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| -rw-r--r-- | src/qmllint/qqmljslintertypepropagator.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/qmllint/qqmljslintertypepropagator.cpp b/src/qmllint/qqmljslintertypepropagator.cpp index d522186803..0c01baf5fd 100644 --- a/src/qmllint/qqmljslintertypepropagator.cpp +++ b/src/qmllint/qqmljslintertypepropagator.cpp @@ -140,7 +140,7 @@ void QQmlJSLinterTypePropagator::checkWrite(const QQmlJSRegisterContent &callBas if (m_typeResolver->memberType(callBase, propertyName).isProperty()) return; auto containedType = callBase.containedType(); - if (!containedType) + if (!containedType || !checkTypeResolved(containedType)) return; const QString internalName = callBase.containedType()->internalName(); if (internalName == "QJSValue"_L1 || internalName == "QVariant"_L1) diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 9a96c211bf..8ec2bc5071 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -4529,6 +4529,32 @@ Item { .addUnexpected("Type \"MyObject1\" of property \"myObj\" not found."_L1) .build() << defaultOptions; + + QTest::newRow("propertyWriteUsage") + << uR"(import MissingRegistration +import QtQuick +Item { + MyObject1 { id: myObj; } + function f() { myObj.hello = 42; } +})"_s + << ResultBuilder() + .addExpected("MyObject1 was not found"_L1, 4, 5) + .addUnexpected("Member \"hello\" not found on type"_L1) + .build() + << defaultOptions; + + QTest::newRow("propertyWriteUsage2") + << uR"(import MissingRegistration +import QtQuick +Item { + property MyObject1 myObj + function f() { myObj.hello = 42; } +})"_s + << ResultBuilder() + .addExpected("MyObject1 was not found"_L1, 4, 5) + .addUnexpected("Member \"hello\" not found on type"_L1) + .build() + << defaultOptions; } void TestQmllint::missingRegistration() |
