diff options
author | Ulf Hermann <[email protected]> | 2022-03-31 11:26:09 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2022-04-04 09:09:49 +0200 |
commit | aea732d607dbcc7ba2c86244ca1ab9086bb28ca6 (patch) | |
tree | e835adb7bb9dcf26821f8ea68ed14f0ddb4a3249 /src/qmlcompiler/qqmljsimportvisitor_p.h | |
parent | 6eaef57cd1fb22ce8070eaf090f4cc111b6f1c95 (diff) |
Avoid copying QQmlJSScope
The factory should populate the pre-existing scope rather than copy it
into place. This way we can detect inheritance cycles involving the
pre-existing scope.
However, now we may detect the inheritance cycles earlier, when
resolving the types inside the lazy loading. We have the right pointers
available there now, after all. Therefore, add a way to propagate base
type errors out of the factory. When clearing the base type, we can now
give a reason for that. When checking the inheritance cycles we
retrieve that reason and log it.
We also remove the special casing of the ScopeType property of
QQmlJSScope. There is no real reason to set it in the ctor. As we
delay the population of QQmlJSScope now, we have to set it later.
Pick-to: 6.2 6.3
Task-number: QTBUG-102153
Change-Id: I49cf6e20f59fbdb6ed98a82040b3b159676f5975
Reviewed-by: Andrei Golubev <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor_p.h')
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor_p.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor_p.h b/src/qmlcompiler/qqmljsimportvisitor_p.h index 69714ced36..e9347a49f0 100644 --- a/src/qmlcompiler/qqmljsimportvisitor_p.h +++ b/src/qmlcompiler/qqmljsimportvisitor_p.h @@ -61,12 +61,13 @@ struct QQmlJSResourceFileMapper; class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSImportVisitor : public QQmlJS::AST::Visitor { public: - QQmlJSImportVisitor(QQmlJSImporter *importer, QQmlJSLogger *logger, + QQmlJSImportVisitor(const QQmlJSScope::Ptr &target, + QQmlJSImporter *importer, QQmlJSLogger *logger, const QString &implicitImportDirectory, const QStringList &qmldirFiles = QStringList()); ~QQmlJSImportVisitor(); - QQmlJSScope::Ptr result() const; + QQmlJSScope::Ptr result() const { return m_exportedRootScope; } QQmlJSLogger *logger() { return m_logger; } @@ -161,7 +162,7 @@ protected: QStringList m_qmldirFiles; QQmlJSScope::Ptr m_currentScope; QQmlJSScope::Ptr m_savedBindingOuterScope; - QQmlJSScope::Ptr m_exportedRootScope; + const QQmlJSScope::Ptr m_exportedRootScope; QQmlJSScope::ConstPtr m_globalScope; QQmlJSScopesById m_scopesById; QQmlJSImporter::ImportedTypes m_rootScopeImports; @@ -226,6 +227,7 @@ protected: void breakInheritanceCycles(const QQmlJSScope::Ptr &scope); void checkDeprecation(const QQmlJSScope::ConstPtr &scope); void checkGroupedAndAttachedScopes(QQmlJSScope::ConstPtr scope); + bool rootScopeIsValid() const { return m_exportedRootScope->sourceLocation().isValid(); } QQmlJSLogger *m_logger; enum class LiteralOrScriptParseResult { Invalid, Script, Literal }; @@ -300,6 +302,10 @@ private: const QString &what, const QQmlJS::SourceLocation &srcLocation = QQmlJS::SourceLocation()); void addImportWithLocation(const QString &name, const QQmlJS::SourceLocation &loc); + void populateCurrentScope(QQmlJSScope::ScopeType type, const QString &name, + const QQmlJS::SourceLocation &location); + void enterRootScope(QQmlJSScope::ScopeType type, const QString &name, + const QQmlJS::SourceLocation &location); }; QT_END_NAMESPACE |