aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-04-01 14:21:02 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-04-04 13:51:30 +0200
commit5f95610039f7077343815e2e0a6837b89ccfe9cd (patch)
tree19be4074dc967c7d8ec4d8575c5763701d269925
parent1921e41196d166c51ce3b7f363d8e7563fe29511 (diff)
QmlCompiler: Improve ambiguous type detection
When detecting an ambiguous type, we need to invalidate the entry in the list of types, rather than delete it. If we delete it and we get yet another version of the type, we'll add that one just like it was not ambiguous. Furthermore, we cannot check the type name when looking for ambiguity. The QML name can be bent and twisted in various ways, to import ambiguous-looking types under different names, so that they are actually not ambiguous. Fixes: QTBUG-102153 Change-Id: Iee7951229c5f68b168899e55164e8cf91587eec1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit c12f0f07f577d4a2c58fd139d0ca0b7aac39fda9)
-rw-r--r--src/qmlcompiler/qqmljsimporter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp
index d04a6c51b2..a9ee30de49 100644
--- a/src/qmlcompiler/qqmljsimporter.cpp
+++ b/src/qmlcompiler/qqmljsimporter.cpp
@@ -240,8 +240,8 @@ void QQmlJSImporter::processImport(const QQmlJSImporter::Import &import,
if (!bestExport.isValid() || valExport.version() > bestExport.version())
bestExport = valExport;
- const auto it = types->qmlNames.constFind(qmlName);
- if (it != types->qmlNames.constEnd()) {
+ const auto it = types->qmlNames.find(qmlName);
+ if (it != types->qmlNames.end()) {
// The same set of exports can declare the same name multiple times for different
// versions. That's the common thing and we would just continue here when we hit
@@ -254,7 +254,7 @@ void QQmlJSImporter::processImport(const QQmlJSImporter::Import &import,
const auto existingExports = seenExports.value(qmlName);
enum { LowerVersion, SameVersion, HigherVersion } seenVersion = LowerVersion;
for (const QQmlJSScope::Export &entry : existingExports) {
- if (entry.type() != qmlName || !isVersionAllowed(entry, version))
+ if (!isVersionAllowed(entry, version))
continue;
if (valExport.version() < entry.version()) {
@@ -280,8 +280,8 @@ void QQmlJSImporter::processImport(const QQmlJSImporter::Import &import,
QQmlJS::SourceLocation()
});
- // Remove the name. We don't know which one to use.
- types->qmlNames.remove(qmlName);
+ // Invalidate the type. We don't know which one to use.
+ it->scope = QQmlJSScope::ConstPtr();
continue;
}
case HigherVersion: