diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-04-07 09:35:09 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-04-10 13:35:00 +0200 |
| commit | 5ff76ab872de6bae9766d52f4f794256ae9eeebf (patch) | |
| tree | e10a18e28262b3d19d7f2955ea7a42579d094eeb /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 8ff4d90918bfc9cc866ccf9d25182b266a2027e0 (diff) | |
Compiler: Use regular lookup for redundant optional lookups
If we can determine that the base of an optional lookup cannot hold null
or undefined, we can simply omit the optional part and generate a
regular get lookup. This is also true whenever we lookup an enum.
Amends fc4ee77116624c784d8c42f2b8e5dbf2f78b6d89
Fixes: QTBUG-135649
Pick-to: 6.9 6.8
Change-Id: I64984fdecc75cd4dbc2274a08aa73b5274fb09b7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 9dd3016809..e2c353fb60 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -131,6 +131,7 @@ private slots: void getLookupOfScript(); void getOptionalLookup(); void getOptionalLookup_data(); + void getOptionalLookupNonVoidableBase(); void getOptionalLookupOnQJSValueNonStrict(); void getOptionalLookupShadowed(); void globals(); @@ -2390,6 +2391,16 @@ void tst_QmlCppCodegen::getOptionalLookup() QCOMPARE(actual, expected); } +void tst_QmlCppCodegen::getOptionalLookupNonVoidableBase() +{ + QQmlEngine engine; + const QUrl document(u"qrc:/qt/qml/TestTypes/GetOptionalLookupNonVoidableBase.qml"_s); + QQmlComponent c(&engine, document); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); +} + void tst_QmlCppCodegen::getOptionalLookupOnQJSValueNonStrict() { QQmlEngine engine; |
