aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscodegenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlcompiler/qqmljscodegenerator.cpp')
-rw-r--r--src/qmlcompiler/qqmljscodegenerator.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp
index dbaec2060d..35902b889a 100644
--- a/src/qmlcompiler/qqmljscodegenerator.cpp
+++ b/src/qmlcompiler/qqmljscodegenerator.cpp
@@ -1575,7 +1575,9 @@ void QQmlJSCodeGenerator::generate_GetLookupHelper(int index)
: u"QQmlPrivate::AOTCompiledContext::InvalidStringId"_s;
const auto accumulatorIn = m_state.accumulatorIn();
const QQmlJSRegisterContent scope = m_state.accumulatorOut().scope();
- const bool isReferenceType = scope.containedType()->isReferenceType();
+ const QQmlJSRegisterContent originalScope
+ = scope.original().isValid() ? scope.original() : scope;
+ const bool isReferenceType = originalScope.containedType()->isReferenceType();
switch (m_state.accumulatorOut().variant()) {
case QQmlJSRegisterContent::Attachment: {
@@ -1637,8 +1639,9 @@ void QQmlJSCodeGenerator::generate_GetLookupHelper(int index)
const QString preparation = getLookupPreparation(
m_state.accumulatorOut(), m_state.accumulatorVariableOut, index);
generateLookup(lookup, initialization, preparation);
- } else if ((scope.containedType()->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence
- || scope.contains(m_typeResolver->stringType()))
+ } else if ((originalScope.containedType()->accessSemantics()
+ == QQmlJSScope::AccessSemantics::Sequence
+ || originalScope.contains(m_typeResolver->stringType()))
&& m_jsUnitGenerator->lookupName(index) == u"length"_s) {
const QQmlJSScope::ConstPtr stored = accumulatorIn.storedType();
if (stored->isListProperty()) {
@@ -1656,6 +1659,14 @@ void QQmlJSCodeGenerator::generate_GetLookupHelper(int index)
m_state.accumulatorOut(),
m_state.accumulatorVariableIn + u".length()"_s)
+ u";\n"_s;
+ } else if (originalScope.contains(m_typeResolver->stringType())) {
+ m_body += m_state.accumulatorVariableOut + u" = "_s
+ + conversion(
+ m_typeResolver->sizeType(), m_state.accumulatorOut(),
+ conversion(m_state.accumulatorIn(), m_typeResolver->stringType(),
+ m_state.accumulatorVariableIn)
+ + u".length()"_s)
+ + u";\n"_s;
} else {
REJECT(u"access to 'length' property of sequence wrapped in non-sequence"_s);
}