diff options
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 27 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/onAssignment.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 4 |
3 files changed, 26 insertions, 12 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 5d858229dd..a1de41e3ca 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -470,21 +470,22 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::FormalParameterList *fpl) bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob) { // property QtObject __styleData: QtObject {...} - QString name; for (auto id = uiob->qualifiedTypeNameId; id; id = id->next) name += id->name.toString() + QLatin1Char('.'); name.chop(1); - QQmlJSMetaProperty prop; - prop.setPropertyName(uiob->qualifiedId->name.toString()); - prop.setTypeName(name); - prop.setIsWritable(true); - prop.setIsPointer(true); - prop.setIsAlias(name == QLatin1String("alias")); - prop.setType(m_rootScopeImports.value(uiob->qualifiedTypeNameId->name.toString())); - m_currentScope->addOwnProperty(prop); + if (!uiob->hasOnToken) { + QQmlJSMetaProperty prop; + prop.setPropertyName(uiob->qualifiedId->name.toString()); + prop.setTypeName(name); + prop.setIsWritable(true); + prop.setIsPointer(true); + prop.setIsAlias(name == QLatin1String("alias")); + prop.setType(m_rootScopeImports.value(uiob->qualifiedTypeNameId->name.toString())); + m_currentScope->addOwnProperty(prop); + } enterEnvironment(QQmlJSScope::QMLScope, name, uiob->qualifiedTypeNameId ? uiob->qualifiedTypeNameId->identifierToken @@ -500,9 +501,11 @@ void QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob) const QQmlJSScope::ConstPtr childScope = m_currentScope; leaveEnvironment(); - QQmlJSMetaProperty property = m_currentScope->property(uiob->qualifiedId->name.toString()); - property.setType(childScope); - m_currentScope->addOwnProperty(property); + if (!uiob->hasOnToken) { + QQmlJSMetaProperty property = m_currentScope->property(uiob->qualifiedId->name.toString()); + property.setType(childScope); + m_currentScope->addOwnProperty(property); + } } bool QQmlJSImportVisitor::visit(ExportDeclaration *) diff --git a/tests/auto/qml/qmllint/data/onAssignment.qml b/tests/auto/qml/qmllint/data/onAssignment.qml new file mode 100644 index 0000000000..b754a7f311 --- /dev/null +++ b/tests/auto/qml/qmllint/data/onAssignment.qml @@ -0,0 +1,7 @@ +import QtQuick + +Item { + property bool pressed: false + SequentialAnimation on pressed {} + property int wrong: pressed.loops +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 18b5090dcf..12b8f5619f 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -292,6 +292,10 @@ void TestQmllint::dirtyQmlCode_data() << QStringLiteral("Signal handler for \"onSig\" has more formal parameters " "than the signal it handles.") << QString(); + QTest::newRow("OnAssignment") + << QStringLiteral("onAssignment.qml") + << QStringLiteral("Property \"loops\" not found on type \"bool\"") + << QString(); } void TestQmllint::dirtyQmlCode() |