diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2024-07-18 10:51:38 +0200 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2024-07-19 21:05:30 +0200 |
| commit | 809455f40b8f23e76528a726a5153d31ad5bf4e8 (patch) | |
| tree | d0fc5d8e56761ecb8a04fe9f4e747197bbc8f9af /src/qmlcompiler/qqmljsimportvisitor.cpp | |
| parent | d944eabb607fa59e1098cbaa9c1e330a90b2bece (diff) | |
qmllint: squash warning for literal and objects together
Replace the "Property %1 of type %2 is assigned an incompatible type %3"
warning with the
"Cannot assign object of type %1 to %2" warning.
From a user perspective, it does not really make sense to have
different warnings for these scenarios:
```
property int xxx: "asdf" // Cannot assign literal ...
property int xxx2: Item {} // old: Property xxx2 of type int ...
property date xxx3: 1 + 1 // Cannot assign binding ...
```
because all are complaining about the exact same thing. Therefore, use
the same warning for all three:
```
property int xxx: "asdf" // Cannot assign literal ...
property int xxx2: Item {} // new: Cannot assign object ...
property date xxx3: 1 + 1 // Cannot assign binding ...
```
Task-number: QTBUG-118112
Pick-to: 6.7 6.8
Change-Id: Ieaf8ca39685b3d03a1fb9238a832e9413c2c1567
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index f8706f5c12..718eda9575 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -767,13 +767,10 @@ void QQmlJSImportVisitor::processPropertyBindingObjects() } if (!objectBinding.onToken && !property.type()->canAssign(childScope)) { - // the type is incompatible - m_logger->log(QStringLiteral("Property \"%1\" of type \"%2\" is assigned an " - "incompatible type \"%3\"") - .arg(propertyName) - .arg(property.typeName()) - .arg(getScopeName(childScope, QQmlSA::ScopeType::QMLScope)), - qmlIncompatibleType, objectBinding.location); + m_logger->log(QStringLiteral("Cannot assign object of type %1 to %2") + .arg(getScopeName(childScope, QQmlSA::ScopeType::QMLScope)) + .arg(property.typeName()), + qmlIncompatibleType, childScope->sourceLocation()); continue; } |
