diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-04-26 11:10:46 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-04-26 14:39:42 +0200 |
commit | 001bec1aa213d47d02efa6a8aed5111aaf67ca7c (patch) | |
tree | f476d1c72ff33671106bd4354a9aa2258f71524b /tools | |
parent | 784c62441333de8d13d31c719ac01e6096247c01 (diff) |
qmllint: Store property's binding type separately
In the past the type of a property's bindings would override the base type.
This would lead to incompatible type warnings when trying to override that binding with another value that was compatible with the property type but not the binding one.
Change-Id: Ie0c0843e34f24e05aae7bbb429899fbe076e7262
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index 1e889926a1..af56e0b2bf 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -115,8 +115,11 @@ void CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members, const auto property = scope->property(access.m_name); if (!property.propertyName().isEmpty()) { - const QString typeName = access.m_parentType.isEmpty() ? property.typeName() - : access.m_parentType; + const auto binding = scope->propertyBinding(access.m_name); + const QString typeName = access.m_parentType.isEmpty() + ? (binding.isValid() ? binding.typeName() : property.typeName()) + : access.m_parentType; + if (property.isList()) { detectedRestrictiveKind = QLatin1String("list"); detectedRestrictiveName = access.m_name; @@ -132,7 +135,11 @@ void CheckIdentifiers::checkMemberAccess(const QVector<FieldMember> &members, } if (access.m_parentType.isEmpty()) { - scope = property.type(); + if (binding.isValid()) + scope = binding.type(); + else + scope = property.type(); + if (scope.isNull()) { // Properties should always have a type. Otherwise something // was missing from the import already. @@ -342,7 +349,10 @@ void CheckIdentifiers::operator()( if (memberAccessChain.isEmpty() || unknownBuiltins.contains(property.typeName())) continue; - if (!property.type()) { + const auto binding = qmlScope->propertyBinding(memberAccessBase.m_name); + if (binding.isValid()) { + checkMemberAccess(memberAccessChain, binding.type(), &property); + } else if (!property.type()) { m_logger->log(QString::fromLatin1( "Type of property \"%2\" not found") .arg(memberAccessBase.m_name), Log_Type, memberAccessBase.m_location); |