QmlCompiler: Fix version resolution for imports
Partially versioned imports should not be sorted useing the generic comparison operators. We have to check each component individually. Pick-to: 6.5 Fixes: QTBUG-110320 Change-Id: Id75ab73ff6a4b5b040b9fcbb426e6bcf893d3d8b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
9e4f6d9211
commit
07185214dd
|
@ -310,8 +310,14 @@ void QQmlJSImporter::importDependencies(const QQmlJSImporter::Import &import,
|
|||
static bool isVersionAllowed(const QQmlJSScope::Export &exportEntry,
|
||||
const QQmlJSScope::Import &importDescription)
|
||||
{
|
||||
return !importDescription.version().isValid()
|
||||
|| exportEntry.version() <= importDescription.version();
|
||||
const QTypeRevision importVersion = importDescription.version();
|
||||
const QTypeRevision exportVersion = exportEntry.version();
|
||||
if (!importVersion.hasMajorVersion())
|
||||
return true;
|
||||
if (importVersion.majorVersion() != exportVersion.majorVersion())
|
||||
return false;
|
||||
return !importVersion.hasMinorVersion()
|
||||
|| exportVersion.minorVersion() <= importVersion.minorVersion();
|
||||
}
|
||||
|
||||
void QQmlJSImporter::processImport(const QQmlJSScope::Import &importDescription,
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import QtQuick.Controls 2 as QQC2
|
||||
|
||||
QQC2.ApplicationWindow {
|
||||
height: 400
|
||||
width: 400
|
||||
visible: true
|
||||
QQC2.Action {} // Action because it appeared in version 2.3
|
||||
}
|
|
@ -1215,6 +1215,7 @@ void TestQmllint::cleanQmlCode_data()
|
|||
QTest::newRow("callBase") << QStringLiteral("callBase.qml");
|
||||
QTest::newRow("propertyWithOn") << QStringLiteral("switcher.qml");
|
||||
QTest::newRow("constructorProperty") << QStringLiteral("constructorProperty.qml");
|
||||
QTest::newRow("onlyMajorVersion") << QStringLiteral("onlyMajorVersion.qml");
|
||||
}
|
||||
|
||||
void TestQmllint::cleanQmlCode()
|
||||
|
|
|
@ -3,7 +3,7 @@ import QualifiedNamesTests 5.0 as MyQualifiedImport
|
|||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
A {}
|
||||
// A {} <- QML_REMOVED_IN_VERSION(6, 0)
|
||||
|
||||
B {}
|
||||
|
||||
|
|
|
@ -686,14 +686,12 @@ void tst_qqmljsscope::qualifiedName()
|
|||
return u""_s;
|
||||
};
|
||||
|
||||
QCOMPARE(root->childScopes().size(), 5);
|
||||
QQmlJSScope::ConstPtr a = root->childScopes()[0];
|
||||
QQmlJSScope::ConstPtr b = root->childScopes()[1];
|
||||
QQmlJSScope::ConstPtr d = root->childScopes()[2];
|
||||
QQmlJSScope::ConstPtr qualifiedA = root->childScopes()[3];
|
||||
QQmlJSScope::ConstPtr qualifiedB = root->childScopes()[4];
|
||||
QCOMPARE(root->childScopes().size(), 4);
|
||||
QQmlJSScope::ConstPtr b = root->childScopes()[0];
|
||||
QQmlJSScope::ConstPtr d = root->childScopes()[1];
|
||||
QQmlJSScope::ConstPtr qualifiedA = root->childScopes()[2];
|
||||
QQmlJSScope::ConstPtr qualifiedB = root->childScopes()[3];
|
||||
|
||||
QCOMPARE(qualifiedNameOf(a), "QualifiedNamesTests/A 5.0");
|
||||
QCOMPARE(qualifiedNameOf(b), "QualifiedNamesTests/B 5.0-6.0");
|
||||
QCOMPARE(qualifiedNameOf(d), "QualifiedNamesTests/D 6.0");
|
||||
QCOMPARE(qualifiedNameOf(qualifiedA), "QualifiedNamesTests/A 5.0");
|
||||
|
|
Loading…
Reference in New Issue