aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsimportvisitor.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-08-10 11:02:18 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-08-26 11:17:17 +0200
commit3dccc843363b26f6e51c9a78be347dd905904e25 (patch)
treef1322c4bbc00a0daaefb6a8eed7d659b2ea0c491 /src/qmlcompiler/qqmljsimportvisitor.cpp
parentf0e5ff83a10a12cb38c3d6770e42f587d9392d51 (diff)
Keep track of implicit and explicit Component
This allows us to ignore them when we e.g. check for required properties. Fixes: QTBUG-95373 Change-Id: I2b02e3c24b4891773ac6619a9e051edd9d87aa1f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index b3de9f3808..528849854a 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -489,8 +489,13 @@ void QQmlJSImportVisitor::processDefaultProperties()
// Assigning any element to a QQmlComponent property implicitly wraps it into a Component
// Check whether the property can be assigned the scope
- if (propType->canAssign(scope))
+ if (propType->canAssign(scope)) {
+ if (propType->causesImplicitComponentWrapping()) {
+ // mark the scope as implicitly wrapped, unless it is a Component
+ scope->setIsWrappedInImplicitComponent(!scope->causesImplicitComponentWrapping());
+ }
continue;
+ }
m_logger->logWarning(
QStringLiteral("Cannot assign to default property of incompatible type"),
@@ -529,6 +534,10 @@ void QQmlJSImportVisitor::processPropertyBindingObjects()
if (property.isValid() && !property.type().isNull()
&& (objectBinding.onToken || property.type()->canAssign(objectBinding.childScope))) {
+
+ if (property.type()->causesImplicitComponentWrapping())
+ objectBinding.childScope->setIsWrappedInImplicitComponent(!objectBinding.childScope->causesImplicitComponentWrapping());
+
QQmlJSMetaPropertyBinding binding =
objectBinding.scope->hasOwnPropertyBinding(propertyName)
? objectBinding.scope->ownPropertyBinding(propertyName)
@@ -629,7 +638,7 @@ void QQmlJSImportVisitor::checkRequiredProperties()
}
for (const auto &defScope : m_objectDefinitionScopes) {
- if (defScope->parentScope() == m_globalScope || defScope->isInlineComponent())
+ if (defScope->parentScope() == m_globalScope || defScope->isInlineComponent() || defScope->isComponentRootElement())
continue;
QVector<QQmlJSScope::ConstPtr> scopesToSearch;
@@ -1611,7 +1620,8 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob)
void QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob)
{
QQmlJSScope::resolveTypes(m_currentScope, m_rootScopeImports, &m_usedTypes);
- const QQmlJSScope::ConstPtr childScope = m_currentScope;
+ // must be mutable, as we might mark it as implicitly wrapped in a component
+ const QQmlJSScope::Ptr childScope = m_currentScope;
leaveEnvironment();
auto group = uiob->qualifiedId;