diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2025-10-16 15:37:26 +0200 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2025-10-21 16:53:03 +0200 |
| commit | adb6b6861b295d0f99746428d02fce4cff5cdc1e (patch) | |
| tree | 4ddf6e06ca0cfad9a3e74732b842dbb23a8d0689 /src/qmlcompiler | |
| parent | 741f4b1262f867a8c3d935eac6b5532058093ddd (diff) | |
qmllint: prefer enums over chained attached type
It seems that FlexboxLayout.Row is actually ambiguous: it could refer to
the "Row" enum value, and to the attached type of "Row" which is
attached on the attached type of "FlexboxLayout".
Fix qmllint to follow the qml engine's interpretation of the thing, and
resolve it as an enum instead of a chained attached type in
QQmlJSTypeResolver.
Pick-to: 6.10 6.8
Fixes: QTBUG-141194
Change-Id: I24e23f5fc92b0d007ff1d628b6286f85a60f10d8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler')
| -rw-r--r-- | src/qmlcompiler/qqmljstyperesolver.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp index 31303f253b..92da98650e 100644 --- a/src/qmlcompiler/qqmljstyperesolver.cpp +++ b/src/qmlcompiler/qqmljstyperesolver.cpp @@ -1556,7 +1556,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType( // If we got a plain type reference we have to check the enums of the _scope_. if (contained == metaObjectType()) - return {}; + return memberEnumType(type.scope(), name); if (contained == variantMapType() || contained->inherits(qmlPropertyMapType())) { QQmlJSMetaProperty prop; @@ -1632,6 +1632,12 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType( } } + // check enums before checking attached types of attached types (chained attached types) + if (type.isType()) { + if (auto result = memberEnumType(type.scope(), name); result.isValid()) + return result; + } + if (QQmlJSScope::ConstPtr attachedBase = typeForName(name)) { if (QQmlJSScope::ConstPtr attached = attachedBase->attachedType()) { if (!genericType(attached)) { @@ -1681,15 +1687,8 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberEnumType( QQmlJSRegisterContent QQmlJSTypeResolver::memberType( QQmlJSRegisterContent type, const QString &name, int lookupIndex) const { - if (type.isType()) { - const auto result = memberType(type, name, type.resultLookupIndex(), lookupIndex); - if (result.isValid()) - return result; - - // If we didn't find anything and it's an attached type, - // we might have an enum of the attaching type. - return memberEnumType(type.scope(), name); - } + if (type.isType()) + return memberType(type, name, type.resultLookupIndex(), lookupIndex); if (type.isProperty() || type.isMethodCall()) return memberType(type, name, type.resultLookupIndex(), lookupIndex); if (type.isEnumeration()) { |
