diff options
-rw-r--r-- | tests/auto/qml/qmllint/data/goodTypeAssertion.qml | 5 | ||||
-rw-r--r-- | tools/qmllint/findunqualified.cpp | 5 | ||||
-rw-r--r-- | tools/qmllint/scopetree.cpp | 6 |
3 files changed, 9 insertions, 7 deletions
diff --git a/tests/auto/qml/qmllint/data/goodTypeAssertion.qml b/tests/auto/qml/qmllint/data/goodTypeAssertion.qml index 6f5f52eb6b..85aaf50d06 100644 --- a/tests/auto/qml/qmllint/data/goodTypeAssertion.qml +++ b/tests/auto/qml/qmllint/data/goodTypeAssertion.qml @@ -1,6 +1,9 @@ import QtQuick 2.0 Item { - property QtObject foo: Item { x: 4 } + id: root + function self() { return root } + + property QtObject foo: self() property real foox: (foo as Item).x } 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); |