aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsbasicblocks.cpp
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2023-08-24 16:02:00 +0200
committerUlf Hermann <[email protected]>2023-08-25 20:36:46 +0200
commitf839171eefbba670536262fa3b847d24bfdc627b (patch)
tree0aef06db416563827580762930910022b7623086 /src/qmlcompiler/qqmljsbasicblocks.cpp
parent555125416eb1a12e15dddb57207ce7d87751a64b (diff)
QmlCompiler: Allow creation of actual QVariantMaps from object literals
There are places where we need this: a, If the method in question actually takes a QVariantMap as argument. b, If the resulting value can be shadowed. In that case we expect a QVariant. The engine has to internally convert to the expected type then. Change-Id: Ic5b3faab4578d64ca757de644fe69660fd70e52a Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/qmlcompiler/qqmljsbasicblocks.cpp')
-rw-r--r--src/qmlcompiler/qqmljsbasicblocks.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qmlcompiler/qqmljsbasicblocks.cpp b/src/qmlcompiler/qqmljsbasicblocks.cpp
index 73b4721848..6a535b9582 100644
--- a/src/qmlcompiler/qqmljsbasicblocks.cpp
+++ b/src/qmlcompiler/qqmljsbasicblocks.cpp
@@ -648,13 +648,19 @@ void QQmlJSBasicBlocks::adjustTypes()
const InstructionAnnotation &annotation = m_annotations[object.instructionOffset];
Q_ASSERT(it->trackedTypes.size() == 1);
- Q_ASSERT(it->trackedTypes[0] == m_typeResolver->containedType(annotation.changedRegister));
+ QQmlJSScope::ConstPtr resultType = it->trackedTypes[0];
+
+ Q_ASSERT(resultType == m_typeResolver->containedType(annotation.changedRegister));
Q_ASSERT(!annotation.readRegisters.isEmpty());
- if (!m_typeResolver->adjustTrackedType(it->trackedTypes[0], it->typeReaders.values()))
- setError(adjustErrorMessage(it->trackedTypes[0], it->typeReaders.values()));
+ if (!m_typeResolver->adjustTrackedType(resultType, it->typeReaders.values()))
+ setError(adjustErrorMessage(resultType, it->typeReaders.values()));
- QQmlJSScope::ConstPtr resultType = it->trackedTypes[0];
+ if (m_typeResolver->equals(resultType, m_typeResolver->varType())
+ || m_typeResolver->equals(resultType, m_typeResolver->variantMapType())) {
+ // It's all variant anyway
+ return;
+ }
const int classSize = m_jsUnitGenerator->jsClassSize(object.internalClassId);
Q_ASSERT(object.argc >= classSize);