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-26 11:35:46 +0200 |
commit | cf82561a75ebef9d20bed21dfc3f050611a08e7f (patch) | |
tree | 743700c177ddd7117bdb132b03d3887f1e0c0a62 /tools | |
parent | 1e03675dd95129702751b40ec80a999ffab7394e (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.
Change-Id: I437e77ff38b7d570451cf27ca84e9897b519413f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 36ac9ab322d00ad8a2139bcf463275e3121bfb1f)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/findunqualified.cpp | 5 | ||||
-rw-r--r-- | tools/qmllint/scopetree.cpp | 6 |
2 files changed, 5 insertions, 6 deletions
diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index 8a216fe748..f382df4b8f 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -949,8 +949,9 @@ void FindUnqualifiedIDVisitor::endVisit(QQmlJS::AST::FieldMemberExpression *fiel QString type; if (auto *binary = cast<BinaryExpression *>(base)) { if (binary->op == QSOperator::As) { - if (auto *right = cast<IdentifierExpression *>(binary->right)) - type = right->name.toString(); + // This is terrible. It's fixed in 6.0. + if (auto *right = cast<Type *>(static_cast<Node *>(binary->right))) + type = right->toString(); } } m_currentScope->accessMember(fieldMember->name.toString(), diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp index 7eda6aab97..e3198d16ab 100644 --- a/tools/qmllint/scopetree.cpp +++ b/tools/qmllint/scopetree.cpp @@ -229,13 +229,11 @@ bool ScopeTree::checkMemberAccess( } } - auto type = types.value(scopeName); + auto type = types.value(access->m_parentType.isEmpty() ? scopeName : access->m_parentType); while (type) { const auto typeIt = type->m_properties.find(access->m_name); if (typeIt != type->m_properties.end()) { - const ScopeTree *propType = access->m_parentType.isEmpty() - ? typeIt->type() - : types.value(access->m_parentType).get(); + const ScopeTree *propType = typeIt->type(); return checkMemberAccess(code, access.get(), propType ? propType : types.value(typeIt->typeName()).get(), types, colorOut); |