diff options
-rw-r--r-- | src/qmlcompiler/qqmljsscope.cpp | 15 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/Things/plugins.qmltypes | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/externalEnumProperty.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 |
4 files changed, 21 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp index 5c3ce8d139..ce4897d20e 100644 --- a/src/qmlcompiler/qqmljsscope.cpp +++ b/src/qmlcompiler/qqmljsscope.cpp @@ -193,11 +193,22 @@ QQmlJSScope::findJSIdentifier(const QString &id) const void QQmlJSScope::resolveTypes(const QQmlJSScope::Ptr &self, const QHash<QString, QQmlJSScope::ConstPtr> &contextualTypes) { - auto findType = [&](const QString &name) { + auto findType = [&](const QString &name) -> QQmlJSScope::ConstPtr { auto type = contextualTypes.constFind(name); if (type != contextualTypes.constEnd()) return *type; + const auto colonColon = name.indexOf(QStringLiteral("::")); + if (colonColon > 0) { + const auto outerType = contextualTypes.constFind(name.left(colonColon)); + if (outerType != contextualTypes.constEnd()) { + for (const auto &innerType : qAsConst((*outerType)->m_childScopes)) { + if (innerType->m_internalName == name) + return innerType; + } + } + } + return QQmlJSScope::ConstPtr(); }; @@ -217,6 +228,8 @@ void QQmlJSScope::resolveTypes(const QQmlJSScope::Ptr &self, Q_ASSERT(intType); // There always has to be a builtin "int" type for (auto it = self->m_enumerations.begin(), end = self->m_enumerations.end(); it != end; ++it) { + if (it->type()) + continue; auto enumScope = QQmlJSScope::create(EnumScope, self); enumScope->m_baseTypeName = QStringLiteral("int"); enumScope->m_baseType = intType; diff --git a/tests/auto/qml/qmllint/data/Things/plugins.qmltypes b/tests/auto/qml/qmllint/data/Things/plugins.qmltypes index 99e1fdc466..9ad8c71468 100644 --- a/tests/auto/qml/qmllint/data/Things/plugins.qmltypes +++ b/tests/auto/qml/qmllint/data/Things/plugins.qmltypes @@ -62,5 +62,6 @@ Module { exports: [ "Things/ItemDerived 1.0" ] + Property { name: "alignment"; type: "Qt::Alignment" } } } diff --git a/tests/auto/qml/qmllint/data/externalEnumProperty.qml b/tests/auto/qml/qmllint/data/externalEnumProperty.qml new file mode 100644 index 0000000000..2ba56a03a4 --- /dev/null +++ b/tests/auto/qml/qmllint/data/externalEnumProperty.qml @@ -0,0 +1,5 @@ +import Things + +ItemDerived { + alignment: Qt.AlignCenter +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index db44193871..9c0077582e 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -382,6 +382,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("layouts depends quick") << QStringLiteral("layouts.qml"); QTest::newRow("attached") << QStringLiteral("attached.qml"); QTest::newRow("enumProperty") << QStringLiteral("enumProperty.qml"); + QTest::newRow("externalEnumProperty") << QStringLiteral("externalEnumProperty.qml"); } void TestQmllint::cleanQmlCode() |