qmllint: Use the raw type for type inference, not the stored one

If we use the stored type, we lose important information.

Change-Id: I09264642cee8da2bd9103d01488855ebbc5648b5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2021-11-15 17:39:04 +01:00
parent 0a44706d9a
commit 7de2bca4ab
2 changed files with 4 additions and 7 deletions

View File

@ -421,7 +421,7 @@ void TestQmllint::dirtyQmlCode_data()
<< false;
QTest::newRow("anchors3")
<< QStringLiteral("anchors3.qml")
<< QString()
<< QString("Cannot assign binding of type QQuickItem to QQuickAnchorLine")
<< QString()
<< false;
QTest::newRow("nanchors1")
@ -753,7 +753,6 @@ void TestQmllint::dirtyQmlCode()
const QString output = runQmllint(filename, [&](QProcess &process) {
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QEXPECT_FAIL("anchors3", "We don't see that QQuickItem cannot be assigned to QQuickAnchorLine", Abort);
QEXPECT_FAIL("attachedPropertyAccess", "We cannot discern between types and instances",
Abort);
QEXPECT_FAIL("attachedPropertyNested", "We cannot discern between types and instances",

View File

@ -296,9 +296,9 @@ bool Codegen::generateFunction(const QV4::Compiler::Context *context, Function *
for (const QQmlJS::AST::BoundName &argument : qAsConst(arguments)) {
if (argument.typeAnnotation) {
const auto rawType = m_typeResolver->typeFromAST(argument.typeAnnotation->type);
if (const auto storedType = m_typeResolver->storedType(
if (m_typeResolver->storedType(
rawType, QQmlJSTypeResolver::ComponentIsGeneric::Yes)) {
function->argumentTypes.append(storedType);
function->argumentTypes.append(rawType);
continue;
} else {
return error(QStringLiteral("Cannot store the argument type %1.")
@ -323,10 +323,8 @@ bool Codegen::generateFunction(const QV4::Compiler::Context *context, Function *
}
if (function->returnType) {
if (auto returnType = m_typeResolver->storedType(
if (!m_typeResolver->storedType(
function->returnType, QQmlJSTypeResolver::ComponentIsGeneric::Yes)) {
function->returnType = returnType;
} else {
return error(QStringLiteral("Cannot store the return type %1.")
.arg(function->returnType->internalName()));
}