Fix string type name in qmllint

The "length" property is special cased because it's the only own
property of any JavaScript built-in type. As we've changed the internal
name of the string type in builtins.qmltypes, we need to reflect this in
qmllint.

Fixes: QTBUG-92447
Pick-to: 6.0 6.1
Change-Id: I9a5c7e9ab3da686bb6ac3fdffa36269abb0eb6ea
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2021-04-07 10:13:03 +02:00
parent 547f5761cb
commit b28c8c87ec
3 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,9 @@
import QtQuick 2.15
TextInput {
id: textInput
Component.onCompleted: {
console.log("text.length", textInput.text.length);
}
}

View File

@ -620,6 +620,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("Used imports") << QStringLiteral("used.qml");
QTest::newRow("Unused imports (multi)") << QStringLiteral("unused_multi.qml");
QTest::newRow("compositeSingleton") << QStringLiteral("compositesingleton.qml");
QTest::newRow("stringLength") << QStringLiteral("stringLength.qml");
}
void TestQmllint::cleanQmlCode()

View File

@ -124,7 +124,7 @@ void CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members,
continue;
}
if (typeName == QLatin1String("string")) {
if (typeName == QLatin1String("QString")) {
detectedRestrictiveKind = typeName;
detectedRestrictiveName = access.m_name;
expectedNext.append(QLatin1String("length"));