aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-04-20 12:28:56 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-04-23 13:30:02 +0200
commit09c8684a95277cd60f14ef712f0da58eded9cfbe (patch)
treef340e9ac4fb873462e103e582ba1d318e8e0eb6f /tools
parent45ba08cfd860841f3311d89480618e6f580c8aa4 (diff)
qmllint: Fix several type checking issues
- Fixes the issue of QQmlComponent properties showing a type mismatch that isn't there - Fixes duplicate scopes with the same internal name not being recognized as type matches - Does not warn about incomplete / unresolvable types being incompatible anymore Task-number: QTBUG-92571 Change-Id: Ia4399c44b87fee6614f2b8c95cb28fcaeec780b4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/findwarnings.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 9e9301b104..51db82cbde 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -157,8 +157,10 @@ void FindWarningVisitor::checkDefaultProperty(const QQmlJSScope::ConstPtr &scope
return;
}
if (defaultPropertyName.isEmpty()) {
- m_logger.log(QStringLiteral("Cannot assign to non-existent default property"),
- Log_Property, scope->sourceLocation() );
+ if (scope->parentScope()->isFullyResolved()) {
+ m_logger.log(QStringLiteral("Cannot assign to non-existent default property"),
+ Log_Property, scope->sourceLocation());
+ }
return;
}
@@ -176,20 +178,16 @@ void FindWarningVisitor::checkDefaultProperty(const QQmlJSScope::ConstPtr &scope
}
m_scopeHasDefaultPropertyAssignment[scopeOfDefaultProperty] = true;
- auto propType = defaultProp.type().data();
- if (!propType) // should be an error somewhere else
+ auto propType = defaultProp.type();
+ if (propType.isNull() || !propType->isFullyResolved()
+ || !scope->isFullyResolved()) // should be an error somewhere else
return;
// Assigning any element to a QQmlComponent property implicitly wraps it into a Component
- if (defaultProp.typeName() == QStringLiteral("QQmlComponent"))
+ // Check whether the property can be assigned the scope
+ if (propType->canAssign(scope))
return;
- // scope's type hierarchy has to have property type
- for (const QQmlJSScope *type = scope.data(); type; type = type->baseType().data()) {
- if (type == propType)
- return;
- }
-
m_logger.log(QStringLiteral("Cannot assign to default property of incompatible type"),
Log_Property, scope->sourceLocation());
}
@@ -275,6 +273,9 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb)
return true;
}
+ if (!qmlScope->isFullyResolved())
+ return true;
+
const QString signal = signalName(name);
if (signal.isEmpty()) {
for (const auto &childScope : qmlScope->childScopes()) {