QmlCompiler: Properly check contained type for enums
In case of an enum the actual contained type is the one the enum dictates. This brings registerContains() in line with containedType() and makes it possible to match previously discovered types on subsequent passes of the type propagator. Therefore, it avoids infinite loops where the same types would be tracked over and over. Pick-to: 6.4 Fixes: QTBUG-107176 Fixes: QTBUG-107542 Change-Id: I4b8d66b157d0ec0ece4ca345cb99a630b8898a1b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
29b3cbb983
commit
1a0c4094e0
|
@ -1275,7 +1275,7 @@ bool QQmlJSTypeResolver::registerContains(const QQmlJSRegisterContent ®,
|
|||
: equals(type, prop.type());
|
||||
}
|
||||
if (reg.isEnumeration())
|
||||
return equals(type, intType());
|
||||
return equals(type, reg.enumeration().type());
|
||||
if (reg.isMethod())
|
||||
return equals(type, jsValueType());
|
||||
return false;
|
||||
|
|
|
@ -152,6 +152,7 @@ set(qml_files
|
|||
toString.qml
|
||||
translation.qml
|
||||
trivialSignalHandler.qml
|
||||
typePropagationLoop.qml
|
||||
typePropertyClash.qml
|
||||
typedArray.qml
|
||||
undefinedResets.qml
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import QtQml
|
||||
|
||||
QtObject {
|
||||
property int j: {
|
||||
var tmp = Qt.PartiallyChecked
|
||||
for (var i = 0; i < Qt.Checked; i++) {}
|
||||
return tmp + i;
|
||||
}
|
||||
}
|
|
@ -139,6 +139,7 @@ private slots:
|
|||
void notNotString();
|
||||
void mathOperations();
|
||||
void inaccessibleProperty();
|
||||
void typePropagationLoop();
|
||||
};
|
||||
|
||||
void tst_QmlCppCodegen::initTestCase()
|
||||
|
@ -2725,6 +2726,17 @@ void tst_QmlCppCodegen::inaccessibleProperty()
|
|||
QCOMPARE(o->property("c").toInt(), 5);
|
||||
}
|
||||
|
||||
void tst_QmlCppCodegen::typePropagationLoop()
|
||||
{
|
||||
QQmlEngine engine;
|
||||
|
||||
QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/typePropagationLoop.qml"_s));
|
||||
QVERIFY2(c.isReady(), qPrintable(c.errorString()));
|
||||
QScopedPointer<QObject> o(c.create());
|
||||
|
||||
QCOMPARE(o->property("j").toInt(), 3);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QmlCppCodegen)
|
||||
|
||||
#include "tst_qmlcppcodegen.moc"
|
||||
|
|
Loading…
Reference in New Issue