diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-04-20 12:28:56 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-04-23 13:30:02 +0200 |
commit | 09c8684a95277cd60f14ef712f0da58eded9cfbe (patch) | |
tree | f340e9ac4fb873462e103e582ba1d318e8e0eb6f /src/qmlcompiler/qqmljsscope_p.h | |
parent | 45ba08cfd860841f3311d89480618e6f580c8aa4 (diff) |
qmllint: Fix several type checking issues
- Fixes the issue of QQmlComponent properties showing a type mismatch that isn't there
- Fixes duplicate scopes with the same internal name not being recognized as type matches
- Does not warn about incomplete / unresolvable types being incompatible anymore
Task-number: QTBUG-92571
Change-Id: Ia4399c44b87fee6614f2b8c95cb28fcaeec780b4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsscope_p.h')
-rw-r--r-- | src/qmlcompiler/qqmljsscope_p.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h index 80129296fe..3a8188a007 100644 --- a/src/qmlcompiler/qqmljsscope_p.h +++ b/src/qmlcompiler/qqmljsscope_p.h @@ -222,6 +222,9 @@ public: bool isPropertyRequired(const QString &name) const; bool isPropertyLocallyRequired(const QString &name) const; + bool isResolved() const { return m_baseTypeName.isEmpty() || !m_baseType.isNull(); } + bool isFullyResolved() const; + QString defaultPropertyName() const { return m_defaultPropertyName; } void setDefaultPropertyName(const QString &name) { m_defaultPropertyName = name; } @@ -292,6 +295,31 @@ public: return {}; } + /*! + \internal + Checks whether \a otherScope is the same type as this. + + In addition to checking whether the scopes are identical, we also cover duplicate scopes with + the same internal name. + */ + bool isSameType(const QQmlJSScope::ConstPtr &otherScope) const + { + return this == otherScope.get() + || (!this->internalName().isEmpty() + && this->internalName() == otherScope->internalName()); + } + + /*! + \internal + Checks whether \a derived type can be assigned to this type. Returns \c + true if the type hierarchy of \a derived contains a type equal to this. + + \note Assigning \a derived to "QVariant" or "QJSValue" is always possible and + the function returns \c true in this case. In addition any "QObject" based \a derived type + can be assigned to a this type if that type is derived from "QQmlComponent". + */ + bool canAssign(const QQmlJSScope::ConstPtr &derived) const; + private: QQmlJSScope(ScopeType type, const QQmlJSScope::Ptr &parentScope = QQmlJSScope::Ptr()); |