summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-12-17 14:44:40 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-01-19 13:15:58 +0100
commit503a7403756ffe48cb86f63a382458f0f7ef910b (patch)
tree5931b19980a28939f8b568637ab95ae474fef304
parent4ebe252e1ea4c21c43a145e3065f5a12e93d72ee (diff)
downloadqtdeclarative-503a7403756ffe48cb86f63a382458f0f7ef910b.tar.gz
QQmlJSScope: Remove dead code
The only type needed for resolving enums is builtin "int". The base type of a composite type is always identified by QML name. Trying to resolve it based on C++ names does nothing at best. Change-Id: I943e2bdac75b9258c5eafaaa8760993e61e59d99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5431bacc8a1525d258cffd03dbb32bb7ed0b3b14) Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
-rw-r--r--src/qmlcompiler/qqmljsimporter.cpp18
-rw-r--r--src/qmlcompiler/qqmljsscope.cpp7
-rw-r--r--src/qmlcompiler/qqmljsscope_p.h3
3 files changed, 19 insertions, 9 deletions
diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp
index b39627f61d..ef69339dbe 100644
--- a/src/qmlcompiler/qqmljsimporter.cpp
+++ b/src/qmlcompiler/qqmljsimporter.cpp
@@ -348,13 +348,27 @@ void QQmlJSImporter::processImport(const QQmlJSImporter::Import &import,
// only happen when enumerations are involved, thus the strategy is to
// resolve enumerations (which can potentially create new child scopes)
// before resolving the type fully
+ const QQmlJSScope::ConstPtr intType = tempTypes.cppNames.value(u"int"_qs);
for (auto it = import.objects.begin(); it != import.objects.end(); ++it)
- QQmlJSScope::resolveEnums(it.value(), tempTypes.cppNames, nullptr);
+ QQmlJSScope::resolveEnums(it.value(), intType);
for (auto it = import.objects.begin(); it != import.objects.end(); ++it) {
const auto &val = it.value();
- if (val->baseType().isNull()) // Otherwise we have already done it in localFile2ScopeTree()
+ if (val->baseType().isNull()) { // Otherwise we have already done it in localFile2ScopeTree()
+ // Composite types use QML names, and we should have resolved those already.
+ // ... except that old qmltypes files might specify composite types with C++ names.
+ // Warn about those.
+ if (val->isComposite()) {
+ m_warnings.append({
+ QStringLiteral("Found incomplete composite type %1. Do not use qmlplugindump.")
+ .arg(val->internalName()),
+ QtWarningMsg,
+ QQmlJS::SourceLocation()
+ });
+ }
+
QQmlJSScope::resolveNonEnumTypes(val, tempTypes.cppNames);
+ }
}
}
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp
index f96fc23c40..d8193e398c 100644
--- a/src/qmlcompiler/qqmljsscope.cpp
+++ b/src/qmlcompiler/qqmljsscope.cpp
@@ -400,7 +400,7 @@ void QQmlJSScope::resolveTypes(const QQmlJSScope::Ptr &self,
const auto resolveAll = [](const QQmlJSScope::Ptr &self,
const QHash<QString, QQmlJSScope::ConstPtr> &contextualTypes,
QSet<QString> *usedTypes) {
- resolveEnums(self, contextualTypes, usedTypes);
+ resolveEnums(self, findType(u"int"_qs, contextualTypes, usedTypes));
resolveType(self, contextualTypes, usedTypes);
};
resolveTypesInternal(resolveAll, updateChildScope, self, contextualTypes, usedTypes);
@@ -413,11 +413,8 @@ void QQmlJSScope::resolveNonEnumTypes(const QQmlJSScope::Ptr &self,
resolveTypesInternal(resolveType, updateChildScope, self, contextualTypes, usedTypes);
}
-void QQmlJSScope::resolveEnums(const QQmlJSScope::Ptr &self,
- const QHash<QString, QQmlJSScope::ConstPtr> &contextualTypes,
- QSet<QString> *usedTypes)
+void QQmlJSScope::resolveEnums(const QQmlJSScope::Ptr &self, const QQmlJSScope::ConstPtr &intType)
{
- const auto intType = findType(QStringLiteral("int"), contextualTypes, usedTypes);
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) {
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h
index 3af667a0a0..5217966250 100644
--- a/src/qmlcompiler/qqmljsscope_p.h
+++ b/src/qmlcompiler/qqmljsscope_p.h
@@ -329,8 +329,7 @@ public:
const QHash<QString, ConstPtr> &contextualTypes,
QSet<QString> *usedTypes = nullptr);
static void resolveEnums(const QQmlJSScope::Ptr &self,
- const QHash<QString, QQmlJSScope::ConstPtr> &contextualTypes,
- QSet<QString> *usedTypes = nullptr);
+ const QQmlJSScope::ConstPtr &intType);
void setSourceLocation(const QQmlJS::SourceLocation &sourceLocation)
{