diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-05-18 16:47:34 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-05-20 16:19:27 +0200 |
commit | 36ac9ab322d00ad8a2139bcf463275e3121bfb1f (patch) | |
tree | 6e1753cc82efefb97a7c630f10202988207c2df3 /tools | |
parent | 50841f233a78b970830e70452e62e8940ef8f061 (diff) |
qmllint: Fix evaluation of type assertions
Previously, type assertions were ignored. The test case didn't fail
because simple type casts were automatically detected when the derived
objects were instantiated and assigned to base type properties.
Pick-to: 5.15
Change-Id: I437e77ff38b7d570451cf27ca84e9897b519413f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 6 | ||||
-rw-r--r-- | tools/qmllint/findwarnings.cpp | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index a9bc58661e..619fe8e4b9 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -186,15 +186,13 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> & if (!detectedRestrictiveName.isEmpty()) continue; - auto type = m_types.value(scopeName); + auto type = m_types.value(access.m_parentType.isEmpty() ? scopeName : access.m_parentType); bool typeFound = false; while (type) { const auto typeProperties = type->properties(); const auto typeIt = typeProperties.find(access.m_name); if (typeIt != typeProperties.end()) { - const ScopeTree::ConstPtr propType = access.m_parentType.isEmpty() - ? typeIt->type() - : m_types.value(access.m_parentType); + const ScopeTree::ConstPtr propType = typeIt->type(); scope = propType ? propType : m_types.value(typeIt->typeName()); typeFound = true; break; diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index cecbf838d7..b177c5f5c4 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -977,8 +977,8 @@ void FindWarningVisitor::endVisit(QQmlJS::AST::FieldMemberExpression *fieldMembe QString type; if (auto *binary = cast<BinaryExpression *>(base)) { if (binary->op == QSOperator::As) { - if (auto *right = cast<IdentifierExpression *>(binary->right)) - type = right->name.toString(); + if (auto *right = cast<TypeExpression *>(binary->right)) + type = right->m_type->toString(); } } m_currentScope->accessMember(fieldMember->name.toString(), |