aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp14
-rw-r--r--tests/auto/qml/qmllint/data/stringLength2.qml10
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
-rw-r--r--tools/qmllint/checkidentifiers.cpp5
4 files changed, 23 insertions, 7 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index befac363ae..b01dcf2205 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -110,9 +110,12 @@ void QQmlJSImportVisitor::resolveAliases()
continue;
m_logger.log(QStringLiteral("Cannot deduce type of alias \"%1\"")
.arg(property.propertyName()), Log_Alias, object->sourceLocation());
+ } else {
+ property.setType(type);
+ if (const QString internalName = type->internalName(); !internalName.isEmpty())
+ property.setTypeName(internalName);
}
- property.setType(type);
object->addOwnProperty(property);
}
@@ -328,11 +331,16 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember)
}
QQmlJSMetaProperty prop;
prop.setPropertyName(publicMember->name.toString());
- prop.setTypeName(std::move(typeName));
prop.setIsList(publicMember->typeModifier == QLatin1String("list"));
prop.setIsWritable(!publicMember->isReadonlyMember);
prop.setIsAlias(isAlias);
- prop.setType(m_rootScopeImports.value(prop.typeName()));
+ if (const auto type = m_rootScopeImports.value(typeName)) {
+ prop.setType(type);
+ const QString internalName = type->internalName();
+ prop.setTypeName(internalName.isEmpty() ? typeName : internalName);
+ } else {
+ prop.setTypeName(typeName);
+ }
prop.setAnnotations(parseAnnotations(publicMember->annotations));
if (publicMember->isDefaultMember)
m_currentScope->setDefaultPropertyName(prop.propertyName());
diff --git a/tests/auto/qml/qmllint/data/stringLength2.qml b/tests/auto/qml/qmllint/data/stringLength2.qml
new file mode 100644
index 0000000000..6dc2942b37
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/stringLength2.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.15
+
+Item {
+ id: foo
+
+ property string s
+ Component.onCompleted: {
+ console.log("s.length", foo.s.length);
+ }
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 4d9049db16..c7a9358e9f 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -621,6 +621,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("Unused imports (multi)") << QStringLiteral("unused_multi.qml");
QTest::newRow("compositeSingleton") << QStringLiteral("compositesingleton.qml");
QTest::newRow("stringLength") << QStringLiteral("stringLength.qml");
+ QTest::newRow("stringLength2") << QStringLiteral("stringLength2.qml");
}
void TestQmllint::cleanQmlCode()
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index cad72f9ff8..911e08034a 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -37,10 +37,7 @@
static const QStringList unknownBuiltins = {
QStringLiteral("alias"), // TODO: we cannot properly resolve aliases, yet
QStringLiteral("QJSValue"), // We cannot say anything intelligent about untyped JS values.
-
- // Same for generic variants
- QStringLiteral("variant"),
- QStringLiteral("var")
+ QStringLiteral("QVariant") // Same for generic variants
};
template<typename Visitor>