diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-09-06 11:52:51 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-06 16:31:10 +0000 |
commit | b763170ba1fe5b33b8ec95f02fb59afa18bd0989 (patch) | |
tree | 2ff46603e3a3686949c26355291721db830c6aa1 | |
parent | 136e02b8696f2546d85e056e4e2429d64692193f (diff) |
Add "As" function to symbol table
Fixes: QTBUG-96099
Change-Id: I0bc50c0a66759c36dc50b2d6ef8e16be8fbba45c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 2426b622e1852a418e97a3be89ea1b3eb18b8fb9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/jittedAsCast.qml | 15 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 13 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 01a7878dae..f27754f4a3 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -2440,6 +2440,7 @@ QHash<const void *, const char *> Runtime::symbolTable() {symbol<UMinus>(), "UMinus" }, {symbol<Instanceof>(), "Instanceof" }, + {symbol<As>(), "As" }, {symbol<In>(), "In" }, {symbol<Add>(), "Add" }, {symbol<Sub>(), "Sub" }, diff --git a/tests/auto/qml/qqmllanguage/data/jittedAsCast.qml b/tests/auto/qml/qqmllanguage/data/jittedAsCast.qml new file mode 100644 index 0000000000..e1798a5d35 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/jittedAsCast.qml @@ -0,0 +1,15 @@ +import QtQml + +QtObject { + property QtObject obj: Timer { + interval: 1 + running: true + repeat: true + onTriggered: { + if (++interval === 10) + running = false + } + } + property bool running: (obj as Timer).running + property int interval: (obj as Timer).interval +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 6226f4ec1a..052d9173a2 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -369,6 +369,8 @@ private slots: void variantListConversion(); void thisInArrowFunction(); + void jittedAsCast(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -6420,6 +6422,17 @@ void tst_qqmllanguage::thisInArrowFunction() QCOMPARE(qvariant_cast<QObject *>(o->property("ffResult")), child); } +void tst_qqmllanguage::jittedAsCast() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("jittedAsCast.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QCOMPARE(o->property("running").toBool(), true); + QTRY_COMPARE(o->property("running").toBool(), false); + QCOMPARE(o->property("interval").toInt(), 10); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |